CSS Nesting in 2026: Native & (ampersand) Without PostCSS
Native CSS nesting landed in all major browsers. No PostCSS, no Sass - just & and clean cascade-aware selectors. Here's what changed and how to use it right.
Why Native CSS Nesting Actually Matters Now
For years, the argument for Sass or PostCSS's nesting plugin was basically one thing: you wanted to write selectors inside other selectors without repeating yourself. That's it. And we shipped an entire build-tool ecosystem to do it. In 2026, every major browser - Chrome 112+, Firefox 117+, Safari 17.2+ - supports native CSS nesting without a single preprocessor in the pipeline.
Look, this isn't just a syntax convenience. Native nesting is spec-aware, cascade-aware, and integrates directly with @layer, @scope, and @media in ways that PostCSS's static transform never could. When you nest inside a @layer, the specificity math stays correct at parse time, not at compile time. That distinction matters more than it sounds the first time you hit a cascade bug at 2am.
Worth noting: PostCSS and Sass still have a role in large, legacy codebases. But if you're starting a project in 2026 - Next.js 15, Vite 6, whatever - you don't need either of them just for nesting. Ship less tooling. The browser handles it.
Honestly, the delay between the spec landing and wide adoption was mostly habit. Developers kept reaching for Sass because nesting was *the* killer feature, and they'd already set up the pipeline. That muscle memory is now tech debt.
The & Selector: What It Is and What It Isn't
The & (nesting selector) represents the parent selector in the current rule. Simple enough. But there are a few gotchas that trip people up when they first switch from Sass.
In Sass, & could be used as a substring: .block + &__element β .block__element. Native CSS nesting does not support that pattern. The & must appear as a standalone selector token, not glued to a string. So .block { &__element {} } is invalid. You'd write .block { & .element {} } or use a dedicated class. This is the single biggest porting friction when migrating from BEM-heavy Sass codebases.
/* Valid native nesting */
.card {
background: #fff;
border-radius: 12px;
/* pseudo-class */
&:hover {
box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
/* pseudo-element */
&::before {
content: '';
display: block;
}
/* descendant (space required) */
& .card__title {
font-size: 1.25rem;
font-weight: 600;
}
/* sibling combinator */
& + & {
margin-top: 16px;
}
}That & + & pattern - selecting adjacent siblings of the same component - is something Sass users rarely discovered, but native nesting makes it obvious and readable. Quick aside: you can also flip the selector order. & .title and .title are equivalent in modern browsers when written inside a rule, but older spec versions required the & prefix for non-pseudo selectors. Always include it for clarity and compatibility.
One more thing - the & inside @media and @layer works exactly as you'd expect, which is a genuine improvement over the mental model you had to maintain with PostCSS transforms.
Nesting With @media, @layer, and @scope
This is where native nesting earns its keep. In Sass or PostCSS, nesting @media queries inside a rule required the preprocessor to hoist them out and rebuild the selectors - you were always looking at transformed output, not what you wrote. Native nesting doesn't transform anything. What you write is what the browser parses.
.hero {
padding: 80px 24px;
font-size: 1rem;
/* responsive nesting - no hoist, no transform */
@media (min-width: 768px) {
padding: 120px 48px;
font-size: 1.125rem;
}
@media (min-width: 1280px) {
padding: 160px 80px;
font-size: 1.25rem;
}
}Nesting inside @layer is where things get genuinely powerful. You can scope your component styles into a named layer and nest @media queries inside the same block. The cascade order is determined by layer declaration, not by specificity wars. If you're building a design system - like the kind you'd ship with Empire UI components - this is the architecture you want.
@layer components {
.button {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 10px 20px;
border-radius: 8px;
font-weight: 500;
transition: background 150ms ease;
&.button--primary {
background: #6366f1;
color: #fff;
&:hover {
background: #4f46e5;
}
}
@media (max-width: 640px) {
width: 100%;
justify-content: center;
}
}
}That said, @scope is the newest player and worth understanding. It lets you define a lower boundary for selector matching - so your .card styles won't bleed into nested .card components inside a slot. CSS Scoping landed in Chrome 118 and Safari 17.4, and nesting inside @scope works natively. For component library work, this combination finally gives CSS the kind of encapsulation that CSS Modules or Shadow DOM used to be the only options for.
Specificity Rules You Need to Know
Native CSS nesting does not change specificity calculation - it just means you write the selectors in a different place. Each nested selector's specificity is calculated independently, exactly as if you'd written it flat. This is different from how some people expected (or hoped) nesting would work.
The & selector itself has the specificity of whatever it represents. If .card has specificity (0,1,0), then & .title inside .card {} produces a final specificity of (0,2,0) - same as .card .title written flat. No magic.
/* These two blocks are specificity-equivalent */
/* Flat */
.nav .nav__link:hover { color: #6366f1; }
/* Nested - same specificity: (0,3,0) */
.nav {
& .nav__link {
&:hover { color: #6366f1; }
}
}In practice, this means deeply-nested CSS can still produce high-specificity selectors that are hard to override - the same trap as deeply-nested Sass. Keep nesting shallow. Two or three levels max. If you're building component variants, reach for @layer or data-* attributes to signal intent without specificity escalation. The css-variables-guide on Empire UI's blog covers how to pair CSS custom properties with this kind of flat, layered architecture.
Migrating From Sass or PostCSS
The migration path from Sass is mostly mechanical, with one sharp edge: the BEM concatenation pattern. Any &__element or &--modifier syntax breaks in native nesting and you'll need to either switch to full class names or use a different naming convention. The fastest path is a global find-and-replace pass to expand the concatenations before removing Sass from your pipeline.
/* Sass - works in Sass, INVALID in native CSS */
.card {
&__title { font-size: 1.25rem; }
&--featured { border: 2px solid gold; }
}
/* Native CSS equivalent */
.card {
& .card__title { font-size: 1.25rem; }
&.card--featured { border: 2px solid gold; }
}For PostCSS users, the postcss-nesting plugin (v12+) already outputs spec-compliant native nesting syntax. If you've been running that plugin, you can literally remove it from your config and your CSS file will still work in the browser unchanged. That's a rare zero-effort migration. Check your postcss.config.js - if postcss-nesting is in there with a version before 10, you might be outputting the old & {} wrapping syntax that older Chrome required. Update or remove it.
Worth noting: SCSS variables, mixins, and @each loops have no native CSS equivalent yet. You'll keep Sass (or move to CSS custom properties + @property) for those features. The goal isn't to eliminate Sass entirely - it's to stop depending on it for nesting specifically, which was always the simplest thing to polyfill. If you want a reference on how custom properties can replace a lot of SCSS variable usage, the css-variables-system article is a good starting point.
Tools to help: sass-migrator has a module migration but nothing specific to nesting. A combination of ESLint's stylelint-plugin-no-sass-vars and a manual grep for &[a-zA-Z] patterns (to catch BEM concatenations) is the most reliable audit approach before you pull Sass out.
Native Nesting in Real Component Styles
Let's put this in context with something you'd actually ship. Here's a glassmorphism card component using native CSS nesting - no Sass, no PostCSS, just a .css file imported directly. You can see this kind of component live in Empire UI's glassmorphism components collection.
/* glass-card.css - no preprocessor required */
@layer components {
.glass-card {
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 16px;
padding: 24px;
color: #fff;
& .glass-card__header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
& .glass-card__title {
font-size: 1.125rem;
font-weight: 600;
margin: 0;
}
}
& .glass-card__body {
font-size: 0.9375rem;
line-height: 1.6;
opacity: 0.85;
}
&:hover {
background: rgba(255, 255, 255, 0.12);
border-color: rgba(255, 255, 255, 0.25);
transition: background 200ms ease, border-color 200ms ease;
}
@media (max-width: 640px) {
padding: 16px;
border-radius: 12px;
}
}
}That's 46 lines - component styles, hover states, a media query, and layer scoping - in a single readable block. No $variables, no @mixin, no build step. The browser parses it directly. If you're also experimenting with visual styles, the gradient generator and box shadow generator tools generate copy-paste CSS that slots cleanly into nesting blocks like this.
One pattern worth adopting: put your transition declarations on the :hover state, not on the base element. It avoids the flash on initial page load where transitions fire as the component mounts. This is a small thing but it shows up in Lighthouse's CLS scores when you have animations triggered by class changes.
In practice, the biggest win from native nesting isn't the syntax - it's the co-location. When you're debugging a component, the hover state, the responsive variant, and the dark-mode override are all in the same block. You stop jumping between a .scss file and a compiled .css file trying to reconcile what the browser actually received.
Browser Support Reality Check and Fallbacks
As of mid-2026, global CSS nesting support sits above 92% according to caniuse. The holdouts are primarily older Samsung Internet and some niche Chromium-based browsers that haven't shipped point releases. For most production apps, that's inside acceptable progressive-enhancement territory.
The fallback strategy is simple: write your fallback rule flat, then write the nested version. Because the cascade handles unknown rules gracefully, browsers that don't support nesting just ignore the nested blocks and use the flat rule.
/* Flat fallback - all browsers */
.btn { background: #6366f1; color: #fff; }
.btn:hover { background: #4f46e5; }
/* Native nesting - Chrome 112+, Firefox 117+, Safari 17.2+ */
@supports selector(&:hover) {
.btn {
background: #6366f1;
color: #fff;
&:hover { background: #4f46e5; }
}
}The @supports selector() at-rule is the right way to gate nesting specifically. It's cleaner than checking for @supports (selector(& .foo)) - just target the :hover pseudo-class pattern as a proxy for nesting support. For most teams in 2026, though, you won't need this guard at all. Ship the nested CSS. If 8% of your users see the flat fallback styles (which are identical in visual output since you're just un-nesting the same declarations), that's a fine tradeoff.
One more thing - Tailwind CSS v4 uses a native CSS pipeline with Lightning CSS instead of PostCSS. Lightning CSS compiles nesting to flat selectors for target browsers automatically, based on your browserslist config. If you're on Tailwind v4, you already have nesting support in your custom CSS files through Lightning's transpiler, even without touching PostCSS. The tailwind-v4-features article covers that pipeline in detail.
FAQ
No. Native CSS nesting requires & to be a standalone selector token. .block { &__element {} } is invalid - you'd write .block { & .block__element {} } instead. This is the main porting gotcha from Sass BEM codebases.
No. Specificity is calculated the same as if you'd written the selectors flat. .card { & .title {} } produces the same specificity as .card .title {} - there's no nesting discount or penalty.
Not for nesting specifically. Chrome 112+, Firefox 117+, and Safari 17.2+ all support native nesting. You only need a preprocessor if you're also using Sass mixins, SCSS variables, or targeting very old browsers below the 92% global support threshold.
Yes, and it's one of the best parts. @media queries nested inside a rule work natively - the browser doesn't need to hoist or transform them. Write the responsive variant right next to the base styles in the same block.