CSS Variables

Joe Attardi on May 09, 2020

This is an excerpt from my upcoming book, Modern CSS. Variables are a common feature in all programming languages. A variable is a way to store a ... [Read Full]
markdown guide

You can change these values with JS?? I didn't realize that. That's huge! That would especially be big if you were using a bunch of variables to change between multiple color themes on a project.


Yup! Makes multiple themes etc. really easy!

One of my side projects is an emoji picker, and I use CSS variables to define the number of emojis per row and the number of visible rows. These can be passed as options to the JS, which then go and update the CSS variables!

Then the width/height/etc is all calculated based on those vars with the calc function.


code of conduct - report abuse