Skip to content

[css-cascade-5] Allow authors to explicitly place unlayered styles in the cascade layer order #6323

Open
@mirisuzanne

Description

@mirisuzanne

Regarding CSS Cascade 5 (cascade layers), @jensimmons commented on another thread about layer ordering:

Would it be possible to allow Authors to set for themselves where in the cascade the "unlayered layer" resides? Maybe they even want to sandwich it in-between. A mechanism that's part of however they define the named layers & determine which layer is "first" & "second", etc.

By default unlayered style come first (lowest cascade priority) in the source order, but this would allow more explicit placement. Roughly (pseudo-code):

EDIT: That's no longer the case. In #6284 we reversed the behavior, and now unlayered styles have the highest priority. This explicit placement would still be useful, since there are use-cases for both approaches.

/* the default behavior */
@layer <unlayered-styles>, reset, framework, components, utilities;

/* placed "in-between" layers */
@layer reset, framework, <unlayered-styles>, components, utilities;

/* placed at the top/end of the layer order */
@layer reset, framework, components, utilities, <unlayered-styles>;

I think that feature makes a lot of sense, and I would likely use it as an author. A few considerations to keep in mind, as we develop a mechanism for this:

  • I would expect it to be repeatable for implicit sub-layers, as well the implicit outer layer
  • Since all layer names are currently custom-idents, we either need a reserved name, or some way of distinguishing the provided implicit-layer ident from author-provided idents.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To Consider

    Status

    TPAC/FTF agenda items

    Status

    Friday morning

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions