CSS Custom Property
A user-defined CSS property that participates in the cascade and inherits down the tree.
A CSS custom property is a variable declared in a style rule and read with var(). Unlike a preprocessor variable, it is a live part of the cascade: it inherits, it can be redefined per element, and it can be changed at runtime.
The behavior that most often surprises people is where substitution happens. A var() reference is resolved at the element where the declaration using it lives, not where the variable was defined. So a rule at the document root that says --brand-color: var(--scoped-thing) resolves at the root — where the scoped value does not exist — and inherits an invalid value everywhere, no matter how many descendants define --scoped-thing. To make a token overridable inside a scope, the reference has to appear in the rule that ultimately applies to the element. See Scoped Styling.
Two further practical notes. A var() that resolves to nothing fails quietly: the property becomes invalid at computed-value time and falls back to inherited or initial, so a radius silently becomes zero and a color silently becomes black. That is a Silent Failure a pixel comparison barely registers. And custom properties are strings until used, so they can hold fragments of any declaration — useful, and a way to build things no type system will check.
See also6
Design Token
Named design decisions — color, spacing, radius, type — stored as data so they can be shared and re-themed.
Design & Interface17 connections
Cascade
The algorithm deciding which declaration wins when several apply to the same element.
Design & Interface9 connections
Scoped Styling
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
Design & Interface10 connections
Dark Mode
Serving an alternate palette for low-light preference, and the three states that implies.
Design & Interface13 connections
Utility-First CSS
Composing styles from many small single-purpose classes rather than authoring semantic rules.
Design & Interface11 connections
Portal
Rendering an element into a different part of the document than its logical parent.
Web Platform15 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from8
- CascadeDesign & Interface
The algorithm deciding which declaration wins when several apply to the same element.
- Dark ModeDesign & Interface
Serving an alternate palette for low-light preference, and the three states that implies.
- Design TokenDesign & Interface
Named design decisions — color, spacing, radius, type — stored as data so they can be shared and re-themed.
- OKLCHDesign & Interface
A perceptually uniform color space that makes lightness and chroma behave predictably.
- PortalWeb Platform
Rendering an element into a different part of the document than its logical parent.
- Scoped StylingDesign & Interface
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
- Shadow DOMWeb Platform
An encapsulated DOM subtree whose styles and structure are isolated from the rest of the page.
- Utility-First CSSDesign & Interface
Composing styles from many small single-purpose classes rather than authoring semantic rules.