CSS Variables: A Complete Guide
Scrimba Articles

EDITOR BRIEF
CSS variables are custom properties: real CSS properties that start with two dashes and are read with var(). They inherit and follow the cascade, which makes them different from Sass variables. The guide covers naming, scoping, fallbacks, JavaScript use, theming, responsive values, @property, and common bugs.
INSIGHTS
Learning CSS variables helps you build reusable styles and understand how CSS inheritance works. Try setting a value on :root, then override it on a smaller selector to see scoping in action.
Learn more with these courses
CodeFriends courses that build on this story. Practice in the browser with nothing to install.
- Introduction to HTML, CSS, and JavaScriptLearn the fundamentals of HTML, CSS, and JavaScript, and build your own website from scratch.Beginner25 Hours
- Introduction to Web Development (Light)Master HTML, CSS, and JavaScript in just 10 hours.Beginner10 Hours
- Python Programming 101Learn Python in just 20 hours! Kickstart your programming journey with this beginner-friendly course.Beginner20 Hours
COMMENTS
Loading comments…