CSS selectors all exist within the same global scope. Anyone who has worked with CSS long enough has had to come to terms with its aggressively global nature — a model clearly designed in the age of documents, now struggling to offer a sane working environment for today's modern web applications. Every selector has the potential to have unintended side effects by setting unwanted elements or clapping with other selectors. More surprisingly, our selectors may even lose out in the global specificity war, ultimate 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 requirements so much discipline just to keep the code at a minimum level of sustainability. But it doesn't have to be this way. Its time to leave the era of global style sheets behind.

This time for local CSS.

In other languages, it the global environment is something to be done rarely, if ever.

In the JavaScript community, thanks to tools like Browserify, Webpack and JSPM, it

Yet, somehow, CSS still seems to be getting a free pass.

Many of us — myself included, until recently — have been working with CSS so long that we don Even then, we的d still need to wait for the majority of our users to be using a browser with own Shadow DOM support.

We OOCSS, SMCSS, BEM and SIGHT, each providing a way for us to avoid naming collisions and emulate sane scoping rules.

We no longer need to add lengthy prefixes to all of our selectors to simulate copying. More components could define their own foo and bar identifiers which — unlike the traditional global selector model—Wouldn

import styles From './MyComponent.css';import React, {Component } From 'react';export default class MyComponent extended Component {
 render() { return ( <div classname="{styles.fooFoo}><div classname="{styles.barBar); }}>The benefits of global CSS — re-use style between components via utility classes, etc. — are still achievable with this model. The key difference is that, just like when we work in other technologies, we need to explicitly import the classes that we depend on. Our code may make many, if any, assumption about the global environment.Writing maintainable CSS is now encouraged, not by

careful adherence to a naming convention

, but by style encapsulation during development. Once you have been sorted working with local CSS, there is really no going back. Experience true local scope in our style sheets — in a way that works across all browsers— is not something to be easily ignored.Introducing local scope has had a significant ripple effect on how we approach our CSS. Nameing conventions, patterns of re-use, and the potential extraction of styles into separate packages are all directly affected by this shift, and we are only at the beginning of this new era of local CSS.

process.env.NODE_ENV = "development"?

'[name][local]____[hash:base64:5]

[hash:base64:5]'
    Understanding the ramifications of this shift is something that we are still working through. With your valuable input and experience, I' :
    'Note: Automatically optimizing style re-use between components would be an amazing step forward, but it definitely requires help from people a lot smarter than me.)

FREE TEXT

Energistically benchmark focused growth strategies via superior supply chains. Compellingly reintermediate mission-critical potentialities whereas cross functional scenarios. Phosfluorescently re-engineer distributed processes without standardized supply chains.