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 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. But it doesn’t have to be this way. It’s time to leave the era of global style sheets behind.
It’s time for local CSS.
In other languages, it’s accepted that modifying the global environment is something to be done rarely, if ever.
In the JavaScript community, thanks to tools like Browserify, Webpack and JSPM, it’s now expected that our code will consist of small modules, each encapsulating their explicit dependencies, exporting a minimal API.
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’t see the lack of local scope as a problem that we can solve without significant help from browser vendors. Even then, we’d still need to wait for the majority of our users to be using a browser with proper Shadow DOM support.
We’ve worked around the issues of global scope with a series of naming conventions like OOCSS, SMACSS, BEM and SUIT, 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 scoping. More components could define their own foo and bar identifiers which — unlike the traditional global selector model—wouldn’t produce any naming collisions.
import styles from './MyComponent.css'; import React, { Component } from 'react'; export default class MyComponent extends Component { render() { return ( <div> <div className={styles.foo}>Foo</div> <div className={styles.bar}>Bar</div> </div> ); }
The benefits of global CSS — style re-use 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 can’t make many, if any, assumptions 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’ve tried working with local CSS, there’s really no going back. Experiencing 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. Naming conventions, patterns of re-use, and the potential extraction of styles into separate packages are all directly affected by this shift, and we’re 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’re still working through. With your valuable input and experimentation, I’m hoping that this is a conversation we can have together as a larger community.
Note: Automatically optimising style re-use between components would be an amazing step forward, but it definitely requires help from people a lot smarter than me.
189 Comments
Comments are closed.
[…] clindamicina fluconazol ovulos[…]
clindamicina fluconazol ovulos
cialis cheapest prices
cialis cheapest prices
overnight cialis
overnight cialis
cialis 50mg price
cialis 50mg price
pharmacy app store
pharmacy app store
non prescription online pharmacy
non prescription online pharmacy
how often can you take cialis
how often can you take cialis
otc viagra australia
otc viagra australia
what is the normal dose of cialis
what is the normal dose of cialis
how to buy female viagra online
how to buy female viagra online
legitimate online pharmacy
legitimate online pharmacy
cialis at walmart
cialis at walmart
viagra for ladies
viagra for ladies
buy viagra pills canada
buy viagra pills canada
where can i buy cheap viagra online
where can i buy cheap viagra online
sildenafil 5 mg price
sildenafil 5 mg price
viagra soft online
viagra soft online
order generic viagra online
order generic viagra online
cialis capsules canada
cialis capsules canada
tadalafil vardenafil
tadalafil vardenafil
does united healthcare cover cialis
does united healthcare cover cialis
cialis los angeles
cialis los angeles
neurontin hiponatremia
neurontin hiponatremia
metronidazole fish
metronidazole fish
sulfamethoxazole for 21 mo old
sulfamethoxazole for 21 mo old
tamoxifen wirkungsmechanismus
tamoxifen wirkungsmechanismus
love story lyrica
love story lyrica
valacyclovir cheap
valacyclovir cheap
furosemide ranbaxy
furosemide ranbaxy
lisinopril notice
lisinopril notice
metformin macrocytosis
metformin macrocytosis
medicine rybelsus
medicine rybelsus
0.05 ml semaglutide
0.05 ml semaglutide
rybelsus equivalent ozempic
rybelsus equivalent ozempic
zoloft with alcohol
zoloft with alcohol
flagyl canada
flagyl canada
mastitis keflex
mastitis keflex
is fluoxetine 10mg addictive
is fluoxetine 10mg addictive
sildenafil pills in india
sildenafil pills in india
duloxetine medication
duloxetine medication
escitalopram online order
escitalopram online order
cymbalta vs effexor weight gain
cymbalta vs effexor weight gain
cephalexin for cats dosage calculator
cephalexin for cats dosage calculator
gabapentin r665
gabapentin r665
Time is passing by
https://hairbyterri.uk/2021/04/26/make-creative-design-of-tatoos/
Time is passing by
https://taka-torba.pl/blog-temat-2
Time is passing by
http://rving-newengland.nervda.com/nervda-live-talk-show/
Time is passing by
https://www.vistra.co.th/how-to-eat-glutathione-for-useful/
ciprofloxacin otic solution 0.2
ciprofloxacin otic solution 0.2
cephalexin and birth control
cephalexin and birth control
why give bactrim and keflex together
why give bactrim and keflex together
bactrim for diverticulitis
bactrim for diverticulitis
Time is passing by
https://manualedamore3.it/5-film-motivazionali-per-dare-una-svolta-alla-tua-vita/
amoxicillin clavulanate side effects
amoxicillin clavulanate side effects
adh vs ddavp
adh vs ddavp
diltiazem hydrochloride
diltiazem hydrochloride
ezetimibe process
ezetimibe process
how long does it take effexor to work
how long does it take effexor to work
half life of flexeril
half life of flexeril
flomax side effects dizziness
flomax side effects dizziness
augmentin medscape
augmentin medscape
contrave taper
contrave taper
citalopram diarrhea
citalopram diarrhea
depakote maximum dosage
depakote maximum dosage
what is diclofenac sodium topical gel used for
what is diclofenac sodium topical gel used for
cozaar drug class
cozaar drug class
brand name for aripiprazole
brand name for aripiprazole
side effects of amitriptyline
side effects of amitriptyline
allopurinol medicine
allopurinol medicine
can dogs take baby aspirin
can dogs take baby aspirin
benefits of ashwagandha for women
benefits of ashwagandha for women
baclofen and tramadol
baclofen and tramadol
what pain reliever can i take with celebrex
what pain reliever can i take with celebrex
celexa 40 mg side effects
celexa 40 mg side effects
buspar half life
buspar half life
how does remeron work in the brain
how does remeron work in the brain
difference between sulfonylureas and repaglinide
difference between sulfonylureas and repaglinide
what does protonix do
what does protonix do
semaglutide for weight loss dose
semaglutide for weight loss dose
actos adverse
actos adverse
acarbose patent
acarbose patent
robaxin withdrawal symptoms
robaxin withdrawal symptoms
Time is passing by
https://kleemotors.ca/featured-vehicle-2017-rolls-royce-wraith-coupe/
abilify antipsychotic
abilify antipsychotic
sitagliptin for heart failure
sitagliptin for heart failure
ivermectin canada
ivermectin canada
synthroid lifetime
synthroid lifetime
tizanidine hcl 2mg street value
tizanidine hcl 2mg street value
tamsulosin hydrochloride sr dutasteride
tamsulosin hydrochloride sr dutasteride
voltaren gel side effects mayo clinic
voltaren gel side effects mayo clinic
cymbalta vs venlafaxine
cymbalta vs venlafaxine
furosemide vs spironolactone in heart failure
furosemide vs spironolactone in heart failure
Time is passing by
https://mjy-shop.com/枸杞ベリー「ウルフベリー」のスーパーフルーツ/
Time is passing by
https://gamelsy.com/6701-my-brother-s-boxers-ch-01-a.html
Time is passing by
https://www.progettodiciotto.it/index.php/component/k2/item/3?limit=10
Time is passing by
https://tobaforindo.com/team-dari-kemenkumham-sumut-sipir-lapas-kelas-ii-a-pematang-siantar-geledah-seluruh-kamar-wbp/
cialis online pills
cialis online pills
most common side effects of sildenafil
most common side effects of sildenafil
tadalafil von cipla versus lily cialis
tadalafil von cipla versus lily cialis
cialis viagra levitra online
cialis viagra levitra online
rx pharmacy shop coupon code
rx pharmacy shop coupon code
hydrocodone indian pharmacy
hydrocodone indian pharmacy
canadian pharmacy levitra
canadian pharmacy levitra
what does sildenafil do
what does sildenafil do
Time is passing by
https://www.happycleaningsrv.com/flip-fluff-routine-best-thing-can-furniture/
ivermectin 3 mg tablet dosage
ivermectin 3 mg tablet dosage
stromectol 6 mg tablet
stromectol 6 mg tablet
vardenafil online
vardenafil online
tadalafil prescription
tadalafil prescription
generic ivermectin cream
generic ivermectin cream
buy ivermectin cream for humans
buy ivermectin cream for humans
viagra without prescription canada
viagra without prescription canada
ivermectin lotion
ivermectin lotion
cost of viagra 50mg
cost of viagra 50mg
ivermectin 3mg tablets
ivermectin 3mg tablets
tadalafil daily dose
tadalafil daily dose
vardenafil 20mg price
vardenafil 20mg price
Time is passing by
https://www.ahawoodworks.com/woodworking-jigs-and-fixtures/
Time is passing by
https://www.bmwclub.ru/proxy.php?link=https://batmanapollo.ru/список-записей-обновляемый/
Time is passing by
https://gaytronic.com/how-to-write-10000-words-a-week/
Time is passing by
https://apprezzamalta.com/malta-leading-group-c1-in-the-uefa-womens-nations-league/
Time is passing by
https://www.knipboetiekvanzuilen.nl/faq-items/fusce-nisi-malesuada-in-commodo-quis-euismod-quis-orci-onteger-vitae-nisl-non-augue-ullamcorpers/
how long does it take gabapentin to kick in
how long does it take gabapentin to kick in
bactrim cotrimoxazole dosage
bactrim cotrimoxazole dosage
still feeling chlamydia symptoms after treatment doxycycline
still feeling chlamydia symptoms after treatment doxycycline
bla coding sequence ampicillin
bla coding sequence ampicillin
pregabalin 50 mg
pregabalin 50 mg
side effects of trazodone 50 mg
side effects of trazodone 50 mg
metformin kidney damage
metformin kidney damage
valacyclovir uses other than herpes
valacyclovir uses other than herpes
dog amoxicillin vs human amoxicillin
dog amoxicillin vs human amoxicillin
can i take an extra lisinopril if my blood pressure is high
can i take an extra lisinopril if my blood pressure is high
keflex para que sirve
keflex para que sirve
ciprofloxacin ear drops side effects
ciprofloxacin ear drops side effects
provigil and nuvigil side effects
provigil and nuvigil side effects
Time is passing by
http://www.pjwestin.com/2017/12/09/bt-sht-stupid-natural-news/
cephalexin diarrhea
cephalexin diarrhea
Time is passing by
https://crescent-edge.com/2023/08/14/lorem-ipsum-dolor-sit-amet-consectetur-2/
Time is passing by
https://gagnonbeach.ca/beaubassin-est/
Time is passing by
https://www.capitalprivado.com.mx/2018/05/21/la-importancia-de-tu-voto-ii/
Time is passing by
http://lkm512-blog.com/mt/mt4i.cgi?id=1
Time is passing by
https://dualsa.com.br/2019/08/14/normas-e-legislacoes-saiba-como-adequar-seu-posto-de-combustivel/
Time is passing by
https://economiasimple.com.ar/los-gatitos-mas-caros-del-mundo-parte-i/
tamoxifen bodybuilding
tamoxifen bodybuilding
Time is passing by
https://futbolbase.pro/sofyan-amrabat-objetivo-de-traspaso-del-liverpool-publica-un-criptico-mensaje/
Time is passing by
https://freshmindsgifts.co.za/domed-decals/
Time is passing by
https://lockdownfestival.nl/zweetvoeten-tijdens-een-festival-tips-om-fris-te-blijven-en-te-genieten/
Time is passing by
https://vomschwarzenorkan.de/2017/11/27/neue-welpen/
Time is passing by
https://www.makersofthemoon.com/the-box-an-ancient-fortress-structure-built-by-giant-aliens/
Time is passing by
http://www.xitang-bbs.cn/home/link.php?url=https://batmanapollo.ru/список-записей-обновляемый/
Time is passing by
https://seo-momentum.com/product/premium-quality-2/
Time is passing by
https://zetor.com.au/blog/2023/10/20/zetor-direct/
Time is passing by
https://www.medicaldisc.eu/co-pre-vas-vieme-urobit/
Time is passing by
https://www.kwieker.nl/2023/02/tip-geef-niet-te-veel-tips/
Time is passing by
https://kaydok-facade.fr/contactez-nous/
Time is passing by
https://magneticlife.eu/polska/zamek-wolek-skarby-i-biala-dama/
Time is passing by
https://cptcorporate.com/general-overview-on-indonesian-licensing-reformation/
Time is passing by
https://www.strategiedivergenti.it/esame-stato-psicologia-3-cose-sapere-consigli-studio-preparazione/
Time is passing by
https://fanonews.com/የፋኖ-ትግል-የኢትዮጵያዊያን-ትግል-ነው/
Time is passing by
https://glazecoffee.com/a-la-recherche-dun-delicieux-chocolat-chaud-maison/
Time is passing by
https://tehetseg.sk/ady-endre-osztondij-2023-eredmenyek/
Time is passing by
https://englishtoconnect.me/talking-about-your-free-time-and-hobbies/
Time is passing by
http://creativeform.net/2022/06/06/10-travel-tips-for-your-first-solo-trip/
Time is passing by
http://www.blackjack-spielen.at/progressive-blackjack/
Time is passing by
https://baeps.org/2017/08/29/баепс-се-включи-в-софия-диша-2017/
Time is passing by
https://www.mittelstaendler-digital.de/datenschutz/
Time is passing by
https://www.ecole-steiner-troyes.org/category/non-classe/
Time is passing by
https://carteanoua.ro/3-trilogii-celebre-pe-care-merita-sa-le-citesti-intr-o-viata/
Time is passing by
https://vickycalavia.com/biofilmografia/
Time is passing by
https://thepurpleelephantproject.org/2021/01/12/hello-world/
Time is passing by
https://www.arctichydro.is/client-7/
Time is passing by
https://abetterbaker.com/miseenplace/
Time is passing by
https://www.besistanbul.com/yoksullugun-obezitesi/
Konya SEO Uzmanı
Konya SEO Uzmanı cok iyi harika biri super bayildimmmmmmmmmm bu ne boyle yaaaa
Time is passing by
https://adwokatfrankowiczow.pl/niewazna-umowa-nordei/
Konya Evden Eve Taşımacılık
Backlink değil, sırtlink! Konya Evden Eve Nakliyat yeni trendleri belirliyor.
Konya Evden Eve Taşımacılık
Etliekmek yemeden Konya Evden Eve Nakliyat olamazsınız.
Time is passing by
https://candoodesign.com/غرفه-شرکت-آریا-بنا-ویژن/
track location by phone number
Track phone location feature works better than similar apps I’ve tried. Worth the download!
buy instagram followers
The followers I bought seemed authentic at first, but engagement is still low.
internet Sitesi Kurma
Web sitesi kurma asamasinda yasadigim sorunlari canli destekle hemen cozduler.
cristiano ronaldo skills
cristiano ronaldo skills hi i am a football skiller
Time is passing by
https://www.symphonygames.net/2016/05/06/and-the-second-one/
Time is passing by
https://www.amaeco.it/2021/05/11/var-group-e-amaeco-insieme-per-un-futuro-green/
Time is passing by
https://gusojanitorialservices.com/reviews-of-guso-janitorial-services/
Time is passing by
https://connectwave.digital/2023/04/09/drive-traffic-and-convert-leads-with-our-expert-digital/
Time is passing by
https://ashercole.com/claridge-house/
Time is passing by
https://volkstanzkreisbraunfels.de/category/erwachsenengruppe/2023/
Time is passing by
https://myeasyzon.com/2017/07/16/when-not-using-credit-cards-can-hurt-you/