CSS Nesting

Native Nesting

Example

Modern browsers support nesting rules inside each other, like Sass. & refers to the parent selector:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
  <style>
    .card {
      font-family: Arial; padding: 12px; border: 1px solid #ddd; border-radius: 8px;
      h3 { margin: 0 0 6px; color: #04AA6D; }
      &:hover { border-color: #04AA6D; }
      .meta { color: #868e96; font-size: 13px; }
    }
  </style>
</head>
<body>

<div class="card"><h3>Nested CSS</h3><p class="meta">Hover the card</p></div>

</body>
</html>

Result

Note: Supported in all current browsers (2023+). For older browsers, a build step (Sass, PostCSS) flattens nesting.