IT lexicon › Web › CSS cascade layers (@layer)

CSS cascade layers (@layer)

Web På svenska → Updated: 2026-05-30

A CSS feature (@layer) that lets you group rules into named layers with an explicit priority order. The layer order wins over specificity — so you can control which style wins without specificity wars or !important.

Problem: in regular CSS, conflicts are decided by specificity (a more specific selector wins), which leads to "specificity wars" — you're forced to write ever more convoluted selectors or resort to !important to override, say, a framework. Cascade layers flip that: you declare a layer order (@layer reset, framework, utilities;) and rules in a later layer ALWAYS win over earlier layers, regardless of specificity. Use case: put a CSS framework in a low layer and your own overrides in a high one → yours always win, without specificity tricks. Unlayered CSS (outside all layers) wins over layered. Widely supported since 2022. One of the bigger improvements to cascade control in decades. Related to CSS custom properties and logical properties.

← Back to the lexicon