The Power (and Fun) of Scope with CSS Custom Properties

Custom properties makes CSS a programming language. There, I said it, no need to reply :). I’m still not in the practice of using CSS variables and I feel that I’m steadily being left behind, and also that I’m missing out on taking some serious shortcuts in my code.

You’re probably already at least a little familiar with CSS variables. If not, here’s a two-second overview: they are really called custom properties, you set them in declaration blocks like --size: 1em and use them as values like font-size: var(--size);, they differ from preprocessor variables (e.g. they cascade), and here’s a guide with way more information.

An excerpt from The Power (and Fun) of Scope with CSS Custom Properties

View original article

Subscribe to our Newsletter

Add your email address and receive an email every Friday covering off everything worth knowing about building your websites responsively.