CSS 3 · Selectors and the box model

Nest rules

Write child rules inside the parent, as in a preprocessor. Supported natively in current browsers.

.card {
  padding: 1rem;

  & h2 {
    margin: 0;
  }

  &:hover {
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
  }
}

Official CSS 3 documentation

More selectors and the box model commands

All selectors and the box model commands · CSS 3 cheatsheet

Was this page helpful?