CSS Variables are great but do you know everything about them?
In this post, I will highlight a few quirks around CSS variables that no one talks...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
Love the invisible characters thing.
Just worked out using vars for prefixed properties can save a lot of data, e.g.:
Loved the last one about using emojis as CSS variable names. I was today years old when I learned about that one!
I can imagine someone has already done this but a library where all properties are emojis would be pretty funny, completely unusable, but funny!
Number 4 is one I have been using extensively, you are right that one is a real life saver if you want to bind the
:root
CSS var to a slider for example.Great list and beautifully written, easy to follow! ❤🦄!
Never heard of empty variables before.
I'm curious what can be use cases of it.
Thanks for the article mate.
Always something new to learn.
There's a lot of stuff you can do with it (if/else, AND, OR, NOR, XOR). I'm thinking of writing an article on this.
Edit: here is the article
I think you misspelled linear-gradient as linaer-gradient at some places
it's done on purpose
But Why?? Must be any reason
read the article to understand :)
Understood but I didn't understand how they make invalid valid?
You can see that the browser is no more crossing the property and using the previous one. An invalid value will be ignored by the browser which is not the case here. It's considered valid and only at "computed time" the value will be invalid
Great article! You did great with explaining the complexities of vars.
One note, it's spelled "unitless" not "uniteless". :-)
Pretty interesting, especially #3. I imagine if you discovered this one because of a situation happening to you, then it must have been a nightmare to debug it!
Indeed, it's a nightmare to debug especially when you have a code like the example I am showing in #4 where all the properties are defined with CSS variables and no hint from the browser which one is not good 😕
Well now I wanna use emojis for my variable names. 😂 Great article!
Adding one extra thing to your awesome list:
dev.to/yaireo/optional-css-transfo...
The empty variables thing is really useful. You can learn more here