CSS custom properties (variables)
A CSS function used to insert the value of a custom property (variable) into other CSS declarations.
What it does: The :root pseudo-class corresponds to the html element and serves as the highest-level global scope. A comma inside the var() function separates the variable name from its default fallback value. CSS custom properties must start with a double dash (--). The dollar sign ($) is used in preprocessors like Sass. Unlike most CSS identifiers, custom property names are case-sensitive. Custom properties follow the cascade and can be redefined inside hover selectors, media queries, or specific classes. Declaring a variable requires starting with two dashes inside a valid CSS selector rule. The var() function retrieves and inserts the value of a declared custom property.
Common mistakes: Line 1 is incorrect because CSS custom properties must begin with a double dash prefix (--), not a single dash. Line 2 is incorrect because when referencing a custom property, the name inside var() must include the double dash prefix (--text-color).
Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
var()Fill in the Blanks
Spot the Error
Create a free class, add this module to a journey, and track who's stuck.
Create a free teacher account →No credit card. No setup fee. Make a class and invite students in under three minutes.
Practice this topic interactively, track progress, and unlock badges.
Start Learning Free →