@layer reset, base, components, utilities;

@layer reset {
  * { margin: 0; padding: 0; }
}
@layer components {
  .button { background: var(--brand); }
}
@layer utilities {
  .mt-0 { margin-top: 0 !important; }
}

Layer order beats source order and specificity

Within a layer, the normal cascade rules still apply. Between layers, whichever layer was declared later always wins - regardless of how specific a selector inside an earlier layer is. That means a component's own styles can no longer be accidentally overridden by a more specific, unrelated selector loaded later in the file.

What this replaces

Most of the !important declarations we've had to add over the years existed purely to force a specific cascade order. Cascade layers let us express that order explicitly and drop the !important escape hatch almost entirely on new projects.

Specificity gets replaced by explicit ordering

Before cascade layers, "which rule wins" depended on a specificity calculation most developers can't recite correctly under pressure, plus source order as a tiebreaker. Layers replace that with something you declare up front: layers listed first lose to layers listed later, regardless of how specific the selectors inside them are.

@layer reset, base, components, utilities;

@layer base {
  h1 { color: navy; }
}
@layer utilities {
  .text-red { color: red; } /* wins even though .text-red has equal specificity */
}

Where this actually helps

Third-party CSS - a component library, a design system package - can be dropped into its own low-priority layer, so your own overrides in a later layer win automatically without a specificity arms race or a trail of !important declarations. It's the cleanest fix yet for the classic "our overrides keep getting overridden by the library's own updates" problem.