How do I use CSS variables?
Define with --name: value; Use with var(--name). They cascade and can be changed with JavaScript for dynamic theming. This makes maintaining themes incredibly easy and efficient.
Are CSS variables supported?
Yes, all modern browsers support CSS custom properties. They work in Chrome, Firefox, Safari, Edge, and mobile browsers. Support is over 95% globally.
Can I change variables with JavaScript?
Absolutely! Use document.documentElement.style.setProperty('--name', 'value') to update variables dynamically. Perfect for dark mode and live theming.