Cascade Layers

suggest change

Cascade layers make precedence between groups of author rules explicit:

@layer reset, base, components, utilities;

@layer base {
  a {
    color: var(--link-color);
  }
}

@layer components {
  .button {
    color: white;
    background: royalblue;
  }
}

@layer utilities {
  .visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: clip;
    clip-path: inset(50%);
  }
}

For normal declarations, a declaration in a later layer wins over one in an earlier layer before selector specificity is compared. Unlayered author styles have priority over normal declarations inside layers, so establish a layer policy deliberately.

Layers reduce the need for escalating specificity or browser-targeting hacks.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents