Back in 2008, Techhui had a discussion around the use of CSS variables in the discussion post, Are CSS variables the future?
Since then the web has come a long ways and Sass and Less are pretty commonly used in web design today.
The W3C also has a draft for CSS variables. Usage is pretty straight forward. You declare your variables with a 'data-' prefix as such:
:root { data-header-color: #06c; }
h1 { background-color: data(header-color); }
This is pretty cutting edge so isn't supported by browsers today but is pretty exciting to me. I personally, would like
to see mixins in the spec as well.
Comment
I can't wait for CSS variables to be natively supported; this will simplify the process of theming websites 10-fold. Until then, it looks like I'll be diving in to LESS ;)
This is very good news. CSS desperately needs variables to be DRY, terse and maximally useful to designers. Having to repeat the same four colors in your color scheme 200 times is ridiculous.
© 2025 Created by Daniel Leuck.
Powered by
You need to be a member of TechHui to add comments!
Join TechHui