Intent to Prototype: CSS cascade layers

Skip to first unread message

Xiaocheng Hu

Aug 11, 2021, 3:42:45 PM8/11/21
to blink-dev

Contact emails




CSS cascade layers (@layer rule and layered @import syntax) provide a structured way to organize and balance concerns within a single origin. Rules within a single cascade layer cascade together without interleaving with style rules outside the layer. This allows authors to achieve a certain cascade ordering for same-origin rules in a proper way.

Note: We will not implement the 'revert-layer' keyword due to its high complexity and likely negative performance impact.

Blink component



Cascade layers allow authors to create layers to represent element defaults, third-party libraries, themes, components, overrides, and etc.—and are able to re-order the cascade of layers in an explicit way. Without cascade layers, currently authors need to tweak, e.g., selector specificity, !import or source ordering to achieve a certain cascade ordering, which is cumbersome and error-prone.

Initial public proposal

Search tags


TAG review

TAG review status

Issues addressed


Interoperability and Compatibility

As a few feature, the only interoperability risk is that other browsers may not agree or follow up to implement.

Gecko: No signal (

WebKit: No signal (

Web developers: Positive (


@layer rules will be surfaced to DevTools in the Style panel to indicate which layer the style rules are in.

Is this feature fully tested by web-platform-tests?

No. Will add a test suite.

Flag name

Requires code in //chrome?


Tracking bug

Estimated milestones

Link to entry on the Chrome Platform Status

This intent message was generated by Chrome Platform Status.

Yoav Weiss

Aug 16, 2021, 9:48:23 AM8/16/21
to Xiaocheng Hu, Andy Davies, blink-dev
I saw +Andy Davies raise an extremely valid concern regarding this, that I share.
This feature seems to encourage developers to add late-discovered and render-blocking CSS @import or @layer statements. That's likely to cause significant performance degradation.
This aligns with concerns I had regarding CSS modules, but without the path forward to eliminating them (interim transpilation, import maps to provide caching benefits, and WebBundles in the future).

I think it'd be better to design this feature with loading performance in mind and make sure that the URLs are readily available to the HTML parser and the preload scanner before it. As we're the first ones to prototype this, now seems like a good time to make such changes.

You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Xiaocheng Hu

Aug 16, 2021, 1:30:34 PM8/16/21
to Yoav Weiss, Xiaocheng Hu, Andy Davies, blink-dev,
+Miriam Suzanne to see if we need any spec revision

That's indeed a serious concern. Thanks!

I think we need to make sure the preload scanner works for layered @import as you suggested, and find a solution to so that developers don't need to worry about serial downloading of stylesheets.

Miriam Suzanne

Aug 16, 2021, 4:00:44 PM8/16/21
to blink-dev,, Andy Davies, blink-dev,,
I don't see any Cascade Layer spec changes that would be helpful here. The concern seems to be with the `@import` rule itself, which already exists, and *is not required* for using Cascade Layers. I expect that most authors will prefer the `@layer` block rule for exactly this reason. But it makes sense to also ensure that authors using `@import` have access to the feature when needed. We don't need to encourage that, but it would be strange not to provide it, the same way we provide media-queries in `@import`. Is the argument that "we should never add new features to the existing `@import` rule, because `@import` is bad"? If so, it seems like a proposal to deprecate `@import` entirely?

Yoav Weiss

Aug 20, 2021, 9:54:30 AM8/20/21
to Miriam Suzanne, blink-dev,, Andy Davies
Maybe I misunderstood the explainer. Looking at the layer rule, it seems to be introducing a brand new way to create imports, which is not obviously restricted to being the first rule in the stylesheet (as import is restricted).
If that's not the case, and such rules are restricted to be the first rules, that makes matters slightly less performance-negative. The concern would then shift to this feature encouraging developers to use imports in places where they previously avoided it, which seems solvable by better documentation, and moving to a pattern of having styles for the different layers declared in the HTML, where they are discoverable.

Miriam Suzanne

Aug 20, 2021, 12:49:28 PM8/20/21
to blink-dev,, blink-dev,, Andy Davies, Miriam Suzanne
I didn't see that the old explainer is linked here. We've made a lot of changes since then, as Cascade Layers moved into the official specification. The Editor's Draft ( is the most up-to-date, though the Working Draft is also pretty reliable at this point ( I'll add a note to the top of my explainer making that clear. If you look at the spec, you'll find that there is no new importing functionality at all. Instead there is an optional layer function added to the `@import` rule, along side the media-query options that already exist on `@import`.

Xiaocheng Hu

Aug 20, 2021, 2:55:39 PM8/20/21
to Miriam Suzanne, blink-dev,,, Andy Davies
On Fri, Aug 20, 2021 at 9:49 AM Miriam Suzanne <> wrote:
I didn't see that the old explainer is linked here.

I probably made a mistake by linking it here, because it says "explainer". Hope it didn't confuse too many people.

I'll unlink it from the chromestatus entry, and only refer to the spec.
Reply all
Reply to author
0 new messages