3 ms·
Anyone knows the reasoning for using `--` as the prefix for variables?
by pintxo 7y ago
Anyone knows the reasoning for using `--` as the prefix for variables?
- philo23 7y agoPresumably they can't just use one dash to avoid clashes with vendor prefixes (-moz-, -webkit- etc.) I don't think I've ever actually checked, but I always assumed valid CSS property names can only be alpha-dash strings.
- have_faith 7y ago> I always assumed valid CSS property names can only be alpha-dash strings They are, although they also aren't allowed to start with a number. But like most things on the web you're not supposed to do some browsers will still let you get away with it.
- gorbert 7y agoThey talk about reasons for choosing `--` here: https://www.xanthir.com/blog/b4KT0 https://www.xanthir.com/blog/b4KT0 TL, DR: There was discussion of using properties that look like `$foo` to define variables, but if they used `$foo` for variables, they would be unable to use it for future "variable-like" things. CSS custom properties behave differently from CSS pre-processor variables and they wanted to make that clear. Additionally, it’s to provide a way for custom properties to be used in any preprocessor.