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 & Interface21 connections
Cascade
The algorithm deciding which declaration wins when several apply to the same element.
Design & Interface12 connections
Scoped Styling
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
Design & Interface11 connections
Dark Mode
Serving an alternate palette for low-light preference, and the three states that implies.
Design & Interface19 connections
Utility-First CSS
Composing styles from many small single-purpose classes rather than authoring semantic rules.
Design & Interface15 connections
Portal
Rendering an element into a different part of the document than its logical parent.
Web Platform18 connections
Related4
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from10
- CascadeDesign & Interface
The algorithm deciding which declaration wins when several apply to the same element.
- Cascading Style SheetsWeb Platform
The language that describes how web pages look, proposed in 1994 to separate presentation from structure, nearly sunk by inconsistent browser support, and grown since into a layout and animation system that does work once reserved for scripts.
- CSS-in-JSWeb Platform
Writing a component's styles in JavaScript alongside its markup and logic, so styles are scoped automatically and can depend on the component's state, an approach popular in the React era whose runtime costs led to build-time variants.
- 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.