CSS nesting
Writing CSS rules inside other rules so they apply to descendants or variants, a feature browsers now support natively.
In more detail
The & stands for the parent selector. Native nesting removes the need for a preprocessor just to group related rules.
Example
.card { & img { border-radius: 8px; } }Related terms
- CSS preprocessor — A tool such as Sass or Less that takes an extended stylesheet language and compiles it into plain CSS before the browser sees it.
- CSS selector — A pattern, such as .card, #menu or nav a, that picks which elements a CSS rule applies to or which elements a DOM query returns.
Taught in
- Modern Selectors: :has(), :is(), :where() And Nesting Standards — Frontend Architecture & Web Platform