DEV Community

Discussion on: Why CSS is difficult to get right?

Collapse
 
couch3ater profile image
Connor Tangney

CSS doesn’t have variables because CSS prefers sharing properties through inheritance.

Oh, but it does!

:root {
  --primary-color: #a7a7a7;
}

.some-element {
  background-color: var(--primary-color);
}

While it's a newer feature, it sees widespread coverage in all major browsers (except everyone's favorite -- IE).

Collapse
 
darthknoppix profile image
Seth Corker

You are correct, all modern browsers support CSS variables in some form. It’s usage is still pretty low however which is why I ignored it.

Collapse
 
couch3ater profile image
Connor Tangney

🤔

Choosing to omit a specific feature is different than concretely stating that the feature is not supported (which is what you've done here).

Either way, excellent read with some very useful information for newcomers!

Thread Thread
 
darthknoppix profile image
Seth Corker

That's a valid point. I've made a correction to the article to highlight the existence of custom properties and cited you and your example in the footnotes.

Thanks for the feedback 🙏