On this page
  1. Cascade, Specificity & Inheritance
  2. Contents
  3. The CSS Value Resolution Pipeline
  4. Cascade Precedence Order (Highest to Lowest)
  5. Specificity Tuple (A, B, C)
  6. Inheritance & Explicit Reset Keywords

Cascade, Specificity & Inheritance

Prev: tutorials | Up: tutorials | Next: Box Model & Formatting Contexts
Rel: Layers, Scope & Custom Properties, Pseudo-Classes, Critical Rendering Path
Ref: MDN Web Docs — Introducing the CSS Cascade
Tags: #public #web #css #tutorials #cascade #specificity


Contents


The CSS Value Resolution Pipeline

For every element and every CSS property, the browser computes a final value in six stages:

  1. Declared value — All matching declarations from author, user, and browser (user-agent) stylesheets.
  2. Cascaded value — The single winning declaration after applying the Cascade rules below.
  3. Specified value — The cascaded value; or if none matched, the inherited value (for inherited properties like color, font-family) or the property's initial value (for non-inherited properties like border, margin).
  4. Computed value — Relative units (em, rem, currentColor) resolved as far as possible without layout.
  5. Used value — Layout-dependent values (auto, % widths, fr tracks) resolved to concrete pixels.
  6. Actual value — Final rendered value after device-pixel rounding.

Cascade Precedence Order (Highest to Lowest)

  1. Transitions (active CSS transitions)
  2. Origin & Importance (note that !important reverses origin and layer priority!):
    • User-agent !important
    • User !important
    • Author !important (earlier @layer beats later @layer; layered !important beats unlayered !important)
    • Animations (@keyframes)
    • Author normal: unlayered styles beat later @layer, which beats earlier @layer
    • User normal
    • User-agent (browser default) normal
  3. Inline style="..." attribute (beats any selector in the same origin/layer)
  4. Specificity (A, B, C)
  5. Source order (later rule wins on an exact tie)

Specificity Tuple (A, B, C)

/* (0, 0, 0) — zero specificity */
:where(nav a) { color: gray; }

/* (0, 1, 1) — 1 class, 1 type */
nav a.active { color: oklch(55% 0.2 250); }

/* (1, 0, 1) — 1 ID, 1 type */
#primary-nav a { color: navy; }

Inheritance & Explicit Reset Keywords

Linked from

Related notes