Testing

CSS Nesting: Browser Support, Syntax, Known Issues

CSS Nesting lets you place style rules inside other rules. Learn the syntax, browser support across Chrome 112+, Firefox 117+, Safari 16.5+, and known issues.

Author

Prince Dewani

May 6, 2026

CSS Nesting is a W3C CSS Nesting Module Level 1 feature that lets authors write one style rule inside another using the & nesting selector to reference the parent. It works in Chrome 112+, Edge 112+, Firefox 117+, Safari 16.5+ on macOS and iOS, Opera 98+, and Samsung Internet 23+, while Internet Explorer never added support.

This guide covers what CSS Nesting is, the browsers that support it, the syntax with examples, how to check support, and the known issues.

What is CSS Nesting?

CSS Nesting is a W3C CSS Nesting Module Level 1 feature that lets authors write one style rule inside another, with child selectors resolved relative to the parent. The & nesting selector points to the outer rule explicitly. The browser parses nested rules natively, with no preprocessor build step required.

Which browsers does CSS Nesting support?

CSS Nesting works in every modern desktop browser and most mobile browsers, with Chrome and Edge shipping it first, Safari adding it in Safari 16.5, and Firefox following in Firefox 117. The relaxed grammar that lifts the leading-symbol restriction reached every major browser by Chrome 120, Safari 17.2, and Firefox 117.

Loading browser compatibility data...

CSS Nesting compatibility in Chrome

Chrome supports CSS Nesting from Chrome 112 on Windows, macOS, Linux, ChromeOS, and Android. The relaxed grammar that allows nested type selectors without a leading & arrived in Chrome 120. Chrome 109 to 111 had CSS Nesting disabled by default behind the experimental Web Platform features flag; Chrome 4 to 108 did not support CSS Nesting at all.

CSS Nesting compatibility in Edge

Microsoft Edge supports CSS Nesting from Edge 112 on Windows, macOS, and Linux, and the relaxed grammar shipped in Edge 120. Edge 109 to 111 needed the experimental Web Platform features flag to use it. Edge 12 to 108 had no support, the same as Chrome since both share the Chromium engine.

CSS Nesting compatibility in Firefox

Firefox supports CSS Nesting from Firefox 117 on Windows, macOS, Linux, and Android, and ships the relaxed grammar by default in the same release. Firefox 115 and 116 had CSS Nesting disabled by default behind the layout.css.nesting.enabled flag in about:config. Firefox 1 to 114 did not support the feature.

CSS Nesting compatibility in Safari

Safari supports CSS Nesting from Safari 16.5 on macOS Big Sur 11 and later, with iOS Safari and iPadOS Safari adding support in the matching Safari 16.5 release. The relaxed grammar that drops the leading-symbol restriction shipped in Safari 17.2 on macOS, iOS, and iPadOS. Safari 3.1 to 16.4 on macOS and iOS 3 to 16.4 on iPhone did not support CSS Nesting.

CSS Nesting compatibility in Opera

Opera supports CSS Nesting from Opera 98 on desktop, with the relaxed grammar arriving in Opera 106. Opera Mobile supports it from Opera Mobile 80 on Android. Opera 9 to 94 and Opera Mobile builds before 80 did not support the feature, since Opera tracks Chromium and inherited nesting only after the upstream feature stabilized.

CSS Nesting compatibility in Samsung Internet

Samsung Internet supports CSS Nesting from Samsung Internet 23 on Galaxy phones and tablets, with the relaxed grammar shipping in Samsung Internet 25. Samsung Internet 4 to 22 did not implement CSS Nesting, so older Galaxy devices that have not received a browser update fall back to flat CSS.

CSS Nesting compatibility in Android Browser

Chrome for Android supports CSS Nesting from Chrome for Android 112 on Android 8 and later, matching desktop Chrome. The legacy stock Android Browser does not implement CSS Nesting, so any old WebView build below Chromium 112 falls back to flat selectors. Firefox for Android supports it from Firefox 117 on Android.

CSS Nesting compatibility in Internet Explorer

Internet Explorer does not support CSS Nesting in any version. IE 5.5 to 11 predate the CSS Nesting Module Level 1 spec, and Microsoft has retired Internet Explorer in favor of Chromium Edge. Sites that still need IE support must precompile nested CSS with Sass, Less, or PostCSS into flat rules.

Note

Note: CSS Nesting breaks across older Safari, Firefox, and Android WebView builds. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!

How does CSS Nesting syntax work?

CSS Nesting wraps a child rule inside its parent rule, and the browser resolves the child selector relative to the parent. The & nesting selector points back to the outer rule and is required when the inner rule starts with a pseudo-class, a compound selector, or places the parent on the right side of a combinator.

The example below shows the same three rules written in flat CSS and in native CSS Nesting, plus a nested @media query. Both forms produce the same matched selectors at runtime.

/* Without nesting (flat CSS) */
.card { padding: 1rem; }
.card h2 { font-size: 1.25rem; }
.card:hover { border-color: blue; }

/* With native CSS Nesting */
.card {
  padding: 1rem;

  h2 {
    font-size: 1.25rem;
  }

  &:hover {
    border-color: blue;
  }

  @media (min-width: 768px) {
    padding: 2rem;
  }
}

A few rules apply across every browser that ships CSS Nesting:

  • Use & for pseudo-classes and compound selectors: Write &:hover, &.active, or &[disabled] when the nested rule should apply to the parent itself, not to a descendant.
  • Tag selectors work directly in the relaxed grammar: Browsers on the relaxed grammar accept h2, p, or button as a nested selector without a leading &. Older versions need .h2, &h2, or :is(h2).
  • @media, @supports, and @container nest the same way: Drop a media query inside a rule and the inner declarations apply only when the query matches, with no need to repeat the outer selector.
  • Specificity follows :is() rules: The & selector matches the specificity of the most-specific selector in the parent list, so nested compound rules can shift specificity in ways flat CSS does not.
  • String concatenation is not possible: Native CSS Nesting cannot build BEM-style selectors like &__title because the parser treats the next token as a separate selector, not a suffix.
...

How do you check if a browser supports CSS Nesting?

Run a quick CSS.supports probe in DevTools, or guard a rule with @supports selector(&) inside a stylesheet. Both paths return a clear yes or no without changing the page.

  • Open DevTools: In Chrome, Edge, or Firefox, press F12 (or Cmd-Option-I on macOS) and switch to the Console tab.
  • Probe with CSS.supports: Paste CSS.supports("selector(&)") and press Enter. A return value of true means native CSS Nesting works in the current browser.
  • Add a feature query in your stylesheet: Wrap nested rules in @supports selector(&) so older browsers ignore them and skip past to the flat fallback below.
  • Reload the page: Refresh and confirm the nested rule applies in the Elements panel. If the rule shows as not matching, the browser is below the supported version range.
  • Cross-check on real devices: Run the same check on iOS Safari, Android Chrome, and Samsung Internet, since older mobile builds lag desktop releases.

The console snippet below packages the probe and prints a one-line yes or no:

// Run in the browser DevTools Console
const supportsNesting = CSS.supports("selector(&)");
console.log("Native CSS Nesting:", supportsNesting ? "yes" : "no");

// Or guard a rule from inside a stylesheet:
// @supports selector(&) {
//   .card { &:hover { border-color: blue; } }
// }

If the probe returns false, fall back to a precompiled flat stylesheet built with PostCSS Nesting, Sass, or Less so the page still renders correctly.

What are the known issues with CSS Nesting?

CSS Nesting is now a W3C Baseline 2023 feature, but a handful of edge cases still trip up production sites. The biggest hits are the strict-versus-relaxed grammar split, specificity surprises, and older mobile browsers.

  • Strict grammar in early Chrome and Safari builds: Chrome 112 to 119, Safari 16.5 to 17.1, and matching iOS builds reject a nested selector that starts with a tag name. Use & or :is() until you can drop those versions.
  • Specificity shifts compared to Sass: The & selector resolves with :is() rules, so nested compound selectors like &.active inherit the highest specificity in the parent list. Flat rules that worked under Sass nesting can lose to native nesting unless you account for it.
  • BEM-style concatenation is impossible: Native CSS Nesting cannot build .block__element from &__element. Sites that depend on this Sass pattern need a build-time tool.
  • Order of declarations matters: Properties placed after a nested rule inside the same block are ignored in some browsers. Place every flat declaration before the first nested rule.
  • Older Safari and iOS lacked support: Safari 3.1 to 16.4 on macOS and iOS 3 to 16.4 cannot parse nested rules. Sites that still serve macOS Big Sur 11.7 visitors or iPhones on iOS 16.4 need a flat fallback.
  • WebView-based apps lag: Hybrid mobile apps shipped on top of an old Android System WebView or an old iOS WKWebView inherit the same gaps as the system browser, which means CSS Nesting may fail in production builds long after the system browser has updated.
  • Linting and IDE support is uneven: Stylelint, PurgeCSS, and several CSS-in-JS tools added native nesting support late, so a passing lint run on one project can fail on another with the same source.

In my experience, the most surprising failure happens with the strict grammar in Chrome 112 to 119. A nested rule like h2 inside .card silently disappears from the cascade, the Elements panel shows the parent as if the inner rule never existed, and the only signal in DevTools is a quiet warning in the Issues tab. Pair every nested type selector with an & during that version window, or wrap the block in @supports selector(&) until you can drop those builds.

...

Citations

All CSS Nesting version numbers and platform notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests