CSSMay 8, 2026 Β· 2 min read

How to Use CSS Nesting (Native, No Preprocessor)

Write cleaner stylesheets with native CSS nesting. Syntax, rules, and migration from Sass/Less.

πŸ“¦
Try the CSS / JS / HTML Minifier
Free, no signup
β†’
DG
Derek Giordano
Designer & Developer
In this guide
01What Native CSS Nesting Is02Nesting Syntax and Rules03Migrating from Sass04Browser Support

What Native CSS Nesting Is

CSS nesting lets you write child selectors inside parent selectors directly in your stylesheet. Instead of .card { } .card .title { } .card .title:hover { } as three blocks, write .card { .title { &:hover { } } }. Same compiled CSS, but source is organized with related styles grouped visually. This was the primary reason for Sass/Less β€” now browsers support it natively. Use the CSS / JS / HTML Minifier to optimize your nested stylesheets for production.

Nesting Syntax and Rules

The ampersand (&) represents the parent selector: .card { & .title { } } equals .card .title { }. For pseudo-classes, & is optional when selector starts with a symbol: .card { :hover { } } works. You can nest media queries and container queries too: .card { @media (width > 768px) { display: grid; } }. Nesting depth should stay at 3–4 levels maximum β€” deeper nesting creates specificity and readability problems.

Migrating from Sass

Migrating from Sass: most Sass nesting translates directly. Key differences: native CSS requires & for element selectors (& h2 { } not just h2 { }), native CSS nesting doesn’t support Sass’s @extend or placeholder selectors, and native CSS variables (var()) replace Sass variables ($var). Migrate gradually β€” native and Sass nesting can coexist during transition.

Browser Support

Supported in Chrome 120+, Firefox 117+, Safari 17.2+, Edge 120+. Global support exceeds 88% and growing rapidly. For older browsers, nested rules are ignored β€” provide flat CSS fallbacks for critical styles or use a PostCSS nesting plugin as a build step. For new projects starting in 2026, native nesting is safe to use as the primary approach.

Frequently Asked Questions

Can I stop using Sass now?+
If you only used Sass for nesting and variables (now CSS custom properties), yes. If you use Sass mixins, loops, or functions, you still need it.
Is there a nesting depth limit?+
No technical limit, but keep depth to 3–4 levels. Deep nesting creates high specificity, making styles hard to override and debug.
Does nesting affect specificity?+
Nested selectors have the same specificity as their equivalent un-nested form. .card .title has the same specificity whether nested or flat.
Try it yourself

Use the CSS Minifier β€” free, no signup required.

⚑ Open CSS / JS / HTML Minifier
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.