Selectors and the cascade

Nesting

Widely availablesince Jun 2026

Replaces: A preprocessor kept only for nesting. Rules nest natively, including media and container queries inside the rule they modify.

See it working

The syntax

.button {
  background: var(--ink);
  &:hover  { background: var(--brand); }
  & .icon  { margin-inline-end: 6px; }
  @media (width < 600px) { width: 100%; }
}
Edit the demo’s CSS

This is the stylesheet running the demo above. Change a value and watch it. Break it on purpose: delete the modern line and you are looking at the fallback.

For browsers without it

A browser without nesting drops the nested rules, so the button would lose its hover colour and its dot. If that browser matters, keep the build step that flattens nesting for one more year; the source can be written nested today either way.

Before you ship it

You cannot glue class names together

The Sass habit of writing &__title inside .card does not work here. Without a combinator the nested selector is read as a type selector, so &Element is invalid and takes the whole block down with it. Write the full class name. Source