/* Declare in :root — global scope */
:root {
--color-primary: #c05c08;
--spacing-md: 16px;
--radius: 8px;
}
/* Usage */
.btn {
background: var(--color-primary);
padding: var(--spacing-md);
border-radius: var(--radius);
}
/* Fallback */
color: var(--text-color, #333);
document.documentElement.style
.setProperty('--color-primary', '#0066cc');
Sass/Less variables are compiled at build time — static. CSS custom properties live in the browser — dynamic, inherited through the DOM, changeable by JS and media queries.