CSS custom property

A value you name yourself in CSS, such as --color-primary: #2563eb, and use elsewhere with var(--color-primary).

In more detail

Custom properties are resolved by the browser while the page runs, so changing one instantly updates everything that uses it. They follow the cascade and are inherited, so redefining one on an element changes it only for that element's subtree. This makes them the natural way to deliver design tokens and themes on the web.

Example

:root { --spacing-md: 1rem; } .card { padding: var(--spacing-md); }

Related terms

Taught in

References