custom-property
Widely availableSince 201797% of users
Commonly known as 'CSS Variables'. They allow you to store values (like colors or sizes) in a name starting with '--' and reuse them throughout your stylesheet using the 'var()' function.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyClassicIt has worked everywhere since April 2017.
The old way and the modern waySee the snippet: Theme variables without a preprocessor →
Old way 7 lines
// Sass/LESS: compile-time only
$primary: #7c3aed;
$spacing: 16px;
.btn {
background: $primary;
padding: $spacing;
}Modern 7 lines
:root {
--primary: #7c3aed;
--spacing: 16px;
}
.btn {
background: var(--primary);
}See how modern your own CSS is.Check your CSS →
Quick example
:root {
--brand-color: #3b82f6;
}
.button {
background-color: var(--brand-color);
}custom-property browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2017.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
49+
31+
9.1+
15+Mobile
49+Android
31+Android
9.3+iOS