The End of Global CSS

Avatar of Chris Coyier
Chris Coyier on

Mark Dalgleish:

Every selector has the potential to have unintended side effects by targeting unwanted elements or clashing with other selectors. More surprisingly, our selectors may even lose out in the global specificity war, ultimately having little or no effect on the page at all.

Any time we make a change to a CSS file, we need to carefully consider the global environment in which our styles will sit. No other front end technology requires so much discipline just to keep the code at a minimum level of maintainability.

Mark goes on to talk about his preprocessing solution. I can’t speak to that, but I do find it interesting how this struggle has permeated front end development for…ever. Just think of these things: frames, iframes, namespacing selectors, careful naming methodologies, web components / shadow DOM, scoped CSS, all: initial;, future concepts – all things designed to combat the difficult “global” nature of CSS.

Direct Link →