HTML & CSS · Senior · Question 31 of 75

What does native CSS nesting (&) give you?

.card {
  padding: 1rem;
  &:hover { background: #eee; }
  .title { font-weight: 600; }
}

Explanation

CSS Nesting is supported by all modern browsers. Differences from Sass: nested selectors behave as if wrapped in :is(), which affects specificity, and you can't concatenate strings like &__title - that's a preprocessor-only feature.

Further reading

Problem with a question

HTML & CSS · Senior · question 31

Test yourself

Take the HTML & CSS · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz