---
title: "Can I nest CSS without Sass?"
description: "Yes. Native CSS nesting works in every major browser. Learn the syntax, when you need the & selector, and how it differs from Sass nesting."
url: https://www.danny.engineering/answer/css/can-i-nest-css-without-sass
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T18:57:00.000Z
tags: ["CSS"]
---

# Can I nest CSS without Sass?

## The short answer


Yes. Native CSS nesting has worked in all major browsers since late 2023, so you can write nested rules in a plain `.css` file with no preprocessor. Use `&` when you want to join a selector to the parent, such as `&:hover` or `&.is-active`.


```css
.card {
  padding: 1rem;
  border-radius: 0.5rem;

  h2 {
    margin-block: 0 0.5rem;
  }

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

  @media (width >= 48rem) {
    padding: 2rem;
  }
}
```


## Why it happens


For years nesting was the main reason people reached for Sass or Less. The CSS Nesting module brought the feature into the language itself. The browser reads a nested rule as if you had written the full selector: `h2` inside `.card` becomes `.card h2`, and `&:hover` becomes `.card:hover`.


The first versions shipped in 2023 (Chrome 112, Safari 16.5) needed a symbol at the start of a nested selector, so `h2` on its own did not work and you had to write `& h2`. The spec was relaxed soon after. Chrome and Edge 120, Firefox 117 and Safari 17.2 all support the relaxed syntax, where you can nest a bare element name. Any browser that is still updated today supports it.


## How to fix it


### Write nested rules directly in your CSS


No build step is needed. Nest descendants, pseudo-classes and at-rules such as `@media`, `@supports` and `@container` inside the parent rule.


```css
.nav {
  display: flex;
  gap: 1rem;

  a {
    color: inherit;
    text-decoration: none;

    &:hover,
    &:focus-visible {
      text-decoration: underline;
    }
  }

  @container (width < 30rem) {
    flex-direction: column;
  }
}
```


### Know when you need the & selector


Without `&`, a nested selector is treated as a descendant. That matters for pseudo-classes and compound selectors.


```css
.button {
  :hover { color: red; }  /* .button :hover  (any hovered descendant) */
  &:hover { color: red; } /* .button:hover   (the button itself) */

  .icon { width: 1em; }   /* .button .icon */
  &.primary { }           /* .button.primary */

  .dark-theme & { }       /* .dark-theme .button */
}
```


Putting `&` at the end, as in the last line, lets you style an element based on an ancestor.


### Do not expect Sass string joining


In Sass, `&__title` inside `.card` produces `.card__title`. Native CSS does not join strings like that; `&` stands for the whole parent selector, not text to glue on. If you use BEM naming, write those selectors at the top level, or keep Sass for that part.


```css
/* Works in Sass, not in native CSS */
.card {
  &__title { font-weight: 700; }
}

/* Native CSS */
.card__title {
  font-weight: 700;
}
```


### Keep a build tool only if you need old browsers


If your analytics show real traffic from browsers older than the versions above, a tool such as Lightning CSS or PostCSS with a nesting plugin can flatten nested rules at build time. You write the same native syntax and drop the plugin later.


## Common pitfalls

- Forgetting `&` on pseudo-classes. `:hover` nested without `&` targets hovered children, not the element itself.
- Specificity surprises. Nested selectors behave as if the parent were wrapped in `:is()`. If the parent list contains an ID, such as `.a, #b`, every nested rule gets ID-level specificity, even for elements that only match `.a`.
- Deep nesting. Four or five levels produce long, highly specific selectors that are hard to override. Two or three levels is usually plenty.
- Mixing declarations after nested rules. It works in current browsers, but putting all plain declarations first keeps the rule easy to read.
- Assuming every Sass feature exists. Nesting is native; mixins, loops and string joining are not.

## Related reading

- [MDN: Using CSS nesting](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting/Using_CSS_nesting)
- [MDN: The nesting selector (&)](https://developer.mozilla.org/en-US/docs/Web/CSS/Nesting_selector)
