:root
A CSS pseudo-class that matches the top element of the document, the html element, where global custom properties are usually set.
In more detail
It has higher specificity than the html type selector, although it matches the same element. Values set on :root are inherited by every element, so it is the natural home for theme tokens.
Related terms
- CSS custom property — A property you define yourself with a double-hyphen name, such as --brand: #0066cc, and read elsewhere with var(--brand).
- pseudo-class — A selector keyword starting with a colon, such as :hover, :checked or :has(), that matches elements by state or relationship rather than by name.
Taught in
- CSS Custom Properties: Scoping, Fallbacks And Theming — Frontend Architecture & Web Platform
- Event Phases: Capturing, Target And Bubbling Demystified — Frontend Architecture & Web Platform