Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 8 min read Announcement mediumAdept

Help choose the syntax for CSS Nesting

The CSS Working Group is choosing between three candidate syntaxes for native CSS nesting, since Sass-style nesting is impossible: browser parsers would read a nested selector like `element:pseudo` as a `property: value` declaration. Option 3 lets nested rules sit directly in the declaration block but forbids them from starting with a letter, so element selectors need `&` or an `:is()` wrapper. Option 4 adds an optional second block after the declarations that holds only nested rules. Option 5 introduces a dedicated `@nest` at-rule. Side-by-side examples cover basics, nested nesting, media queries and cascade layers, and developers are asked to vote in a survey.

Assumes: CSS selectorsSass nesting

Related posts

  • Try out CSS Nesting today

    WebKit mediumAdept

    CSS Nesting, using the community-chosen Option 3 syntax, shipped on by default in Safari Technology Preview 162 and is behind a flag in Chrome Dev. It works much like Sass nesting, but in this version a nested selector must begin with a symbol: a bare element selector like `article` is silently ignored, which you avoid by prefixing `&` or wrapping it in `:is()`. The `&` also places the parent selector explicitly, as in `.component &` or `&:hover` without a descendant space. A later note says Safari Technology Preview 179+ dropped the symbol requirement.

  • CSS Nesting and the Cascade

    WebKit mediumAdept

    CSS Nesting now supports relaxed parsing, so nested selectors no longer need to start with a symbol: `h1 { }` inside `article { }` just works. Firefox 117 and Safari Technology Preview 179 ship it, and Chrome's update is in progress. The `&` still marks where the parent selector goes, as in `article &`. An open question remains about declarations that follow a nested `@supports` block. The current spec, matching Sass, Less and other preprocessors, hoists them so the earlier rule wins, while a developer survey favored preserving source order (62% vs 38%).

  • WebKit Features in Safari 16.5

    WebKit easyNovice

    Safari 16.5 is mainly a polish and bug-fix release that adds CSS Nesting, the :user-valid and :user-invalid pseudo-classes, Apple Pay support for pre-orders and deferred payments, and disabling of the WebCodecs API in Lockdown Mode. Nesting still requires nested element selectors to start with a symbol such as &, a limitation the CSS Working Group hopes to remove. The new form pseudo-classes wait for user interaction before flagging input as invalid, which removes the need for JavaScript workarounds, and they pair well with :has(). Dozens of fixes cover CSS margin-trim, scroll snapping, media playback, WASM SIMD and Web Inspector.

  • Release Notes for Safari Technology Preview 243

    WebKit mediumAdept

    Safari Technology Preview 243 ships WebKit changes 310600@main through 312007@main for macOS Tahoe and Sequoia. The bulk of the release is CSS layout and selector fixes, covering flexbox, grid, aspect-ratio, anchor positioning, `:has()` invalidation and CJK line breaking. It also adds `contain: style` for quote counters, the `insert` keyword for `text-autospace` and the `shadowrootslotassignment` attribute. Other changes include accessibility fixes for VoiceOver, an O(n²) fix for parsing large `<select>` lists, an ES module loader rewrite for top-level await correctness, and several regular expression fixes.

  • StyleX: A Styling Library for CSS at Scale

    Meta Engineering mediumAdept

    StyleX is Meta's build-time CSS-in-JS compiler that extracts style objects into collision-free atomic CSS, replacing the earlier cx system and cutting CSS size by 80% across Facebook, Instagram, WhatsApp and others. A Babel plugin hashes each property-value pair into a class, caches per file, and uses deterministic hashes for defineVars/defineConsts so it never reads imported modules. Merging is predictable (last style wins), and shorthand/longhand, pseudo-class and media-query conflicts are resolved by computing numeric priorities enforced via @layer or a polyfill. Constraints such as banning global and descendant selectors prevent styling at a distance, while stylex.when, dynamic styles via CSS variables, and theming APIs keep it expressive.

The quest for software engineering knowledge.

Look:
Layout: