CSS
CSS VariablesCSS Variables
CSS variables store reusable values throughout a stylesheet.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
CSS custom properties act as variables holding colors, fonts, or sizes. Instead of typing the same exact color code fifty times, developers store it in a variable. Changing the variable updates the color everywhere instantly.
Syntax
Syntax
Example
Example
Key Points
- The `:root` selector creates global variables.
- Variable names must begin with two dashes.
- The `var()` function accesses the stored value.
- JavaScript can update these variables live.