Mechanical ComparisonCSS Custom Properties & Cascade: Baseline · WidelyCSS Specificity & Inheritance: Baseline · Widely

CSS Custom Properties & Cascade vs CSS Specificity & Inheritance

Mechanical Verdict

Selector specificity arbitrates competing rule declarations, whereas custom properties inherit down the DOM tree.

Try CSS Custom Properties & Cascade LabTry CSS Specificity & Inheritance LabRead CSS Custom Properties & Cascade DissectionRead CSS Specificity & Inheritance Dissection

Structured Comparison Matrix

DimensionCSS Custom Properties & CascadeCSS Specificity & Inheritance
Mental ModelCustom properties inherit through the DOM tree and resolve var() at computed-value time, enabling dynamic theming without preprocessor compilation.Cascade resolves Origin, @layer, (A,B,C) specificity, and source order; inherited properties propagate down only when no rule matches.
Maturity & DomainBaseline · Widely · CSS & Layout
Chrome 49+ · Firefox 31+ · Safari 9.1+
Baseline · Widely · CSS & Layout
Chrome 88+ · Firefox 78+ · Safari 14+
PrerequisitesFoundational primitive
When Not to UseWhen not to use custom properties: Avoid putting high-frequency per-frame animation coordinates on :root; animate transform or scope the variable to the single animated element.When not to use #id selectors in CSS: Never style with #id selectors in reusable components; reserve #id for DOM anchors and ARIA labelledby targets.

Engine Mechanics & Trade-Offs

CSS Custom Properties & CascadeBaseline · Widely

Engine stores --var as raw tokens; var() substitutes at computed-value time and falls back to initial/inherited (IACVT) if invalid.

Key Pitfalls: Mutating :root variables on scroll or mousemove: Updating --x on document.documentElement invalidates inherited styles across thousands of elements per frame. Space-toggle tricks: Overly clever --on: initial; --off: ; hacks hurt readability and break minifiers; prefer explicit classes or container style queries.

CSS Specificity & InheritanceBaseline · Widely

Style engine sorts matched declarations by Origin/Importance -> @layer -> (A,B,C) -> Order, then copies inherited properties from parent ComputedStyle.

Key Pitfalls: :is() specificity surprise: :is(#header, .nav) a gives all matches (even .nav a) the #header specificity of (1, 0, 1). Form control inheritance: <button> and <input> have user-agent font and color rules, blocking <body> inheritance unless inherit is set.

Seen in Architecture Autopsies