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.
This article will assist the internet people for creating new weblog or even a blog from
start to end.
If you are going for most excellent contents like me,
just go to see this website every day since it provides quality contents, thanks
Magnificent beat ! I would like to apprentice while you amend your site, how can i subscribe for a blog
site? The account helped me a acceptable deal. I had been tiny
bit acquainted of this your broadcast provided bright clear
concept
Hi Neat post There is a problem along with your website in internet explorer would test this IE still is the market chief and a good section of other folks will pass over your magnificent writing due to this problem
먹튀검증소: https://dyunews.com/
Woah! I’m really loving the template/theme of this site. It’s simple, yet effective.
A lot of times it’s hard to get that “perfect balance” between usability and visual appeal.
I must say you’ve done a fantastic job with this.
Additionally, the blog loads extremely quick for
me on Internet explorer. Exceptional Blog!
An interesting discussion is definitely worth comment.
I do think that you ought to write more about this subject matter,
it may not be a taboo matter but generally people don’t discuss these subjects.
To the next! All the best!!
I think the admin of this web page is truly working hard in support of his
web site, as here every information is quality based material.
ED Trial Packs Brand & Generic . https://valoto.pw/catalog/category/ed-trial-packs
I loved as much as you will receive carried out right here The sketch is attractive your authored material stylish nonetheless you command get got an impatience over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike
Punter Guide escort guide offers sex clubs. https://lorenzoymyk79247.wikilima.com/567434/once_you_hire_dubai_escort_for_bbw_big_booty_blonde_independent_black_latin_lesbian_or_busty_escorts
“As someone new to this subject, I found this article incredibly helpful. The author’s expertise shines through, and the content is presented in a way that is engaging and easy to follow. I’ll be bookmarking this site for future reference!”
“I stumbled upon this blog while researching [topic], and I’m glad I did. The quality of the content speaks volumes about the credibility of the author. I’m impressed by the level of detail and the balanced perspective presented here. Kudos to the team for creating such valuable resources!”
Punter Guide escort guide offers sex clubs. https://zanderfsfr92479.pointblog.net/if-you-want-to-enjoy-the-finest-luxuries-of-dubai-67958490
Injectable Steroids DIANABOL buy online. https://injectable-steroids-dianabol-buy-online.webflow.io
Injectable Steroids DIANABOL buy online. https://ledbookmark.com/story2632770/injectable-steroids-dianabol-buy-online
You made some really good points there. I checked on the web to find out more about
the issue and found most individuals will go along with your views on this website.
I am curious to find out what blog system you’re utilizing?
I’m experiencing some small security problems with my latest website and I
would like to find something more safeguarded. Do you have any
recommendations?
I was curious if you ever thought of changing the
layout of your blog? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people
could connect with it better. Youve got an awful lot
of text for only having 1 or 2 pictures. Maybe you could
space it out better?
Hey there! I’ve been reading your weblog for a long time now
and finally got the bravery to go ahead and give you a shout out from New
Caney Texas! Just wanted to tell you keep up
the good work!
Do you mind if I quote a few of your articles as long as I provide
credit and sources back to your webpage?
My blog is in the very same niche as yours and my users would definitely benefit
from some of the information you provide here. Please let
me know if this alright with you. Regards!
When I originally left a comment I appear to have clicked the -Notify me when new comments are added-
checkbox and from now on every time a comment is added I recieve 4
emails with the same comment. Is there a means you can remove me from that service?
Appreciate it!
Excellent beat ! I wish to apprentice at the same time as you amend your website, how could i
subscribe for a blog web site? The account helped me a
applicable deal. I had been tiny bit familiar of this your broadcast provided shiny clear concept
I am regular visitor, how are you everybody? This article posted at this
website is really good.
Unquestionably believe that which you stated. Your favorite
reason seemed to be on the net the easiest thing to be aware
of. I say to you, I certainly get irked while people think about
worries that they just don’t know about. You managed to hit the nail upon the
top and also defined out the whole thing without
having side effect , people could take a signal.
Will likely be back to get more. Thanks
I read this post fully about the resemblance of newest and previous technologies, it’s awesome article.
Капсулы мухомора для микродозинга купить украина . https://shafa.ua/uk/home/yeda/bakaleya/sukhofrukty/163187510-kapsuly-muhomora-dlya-mikrodozinga-kupit-ukraina-100sht
I’m really impressed with your writing skills and also with the layout on your blog.
Is this a paid theme or did you customize it yourself?
Anyway keep up the nice quality writing, it’s rare to see a nice blog like this one these days.
This website was… how do you say it? Relevant!! Finally I’ve found something which helped
me. Many thanks!
An outstanding share! I have just forwarded this onto a
colleague who has been conducting a little homework on this.
And he actually bought me lunch because I stumbled upon it for
him… lol. So let me reword this…. Thanks for the meal!!
But yeah, thanks for spending the time to discuss this subject here on your web site.
When someone writes an piece of writing he/she retains the thought of a
user in his/her brain that how a user can be aware of it.
Therefore that’s why this paragraph is perfect. Thanks!
What’s up colleagues, how is the whole thing, and what you wish for to say regarding this
piece of writing, in my view its in fact remarkable designed for
me.
What’s up, after reading this awesome article i am also happy to share
my knowledge here with mates.
What’s up, yes this paragraph is in fact pleasant and I
have learned lot of things from it concerning blogging.
thanks.
Thanks , I’ve just been looking for information about this topic for a long time and yours is the best I’ve
came upon so far. But, what concerning the conclusion? Are
you positive in regards to the source?
Have you ever thought about including a little bit more than just your articles?
I mean, what you say is valuable and all. Nevertheless just
imagine if you added some great visuals or video clips
to give your posts more, “pop”! Your content is excellent but with images and videos, this site could certainly be one of the very best in its niche.
Great blog!
Thank you a lot for sharing this with all folks you actually realize what you are talking approximately!
Bookmarked. Please additionally seek advice from my website =).
We could have a hyperlink change contract among us
This article was a fantastic read! I appreciate the depth of information and the clear, concise way it was presented. It’s evident that a lot of research and expertise went into crafting this post, and it really shines through in the quality of the content. I particularly found the first and last sections to be incredibly insightful. It sparked a few thoughts and questions I’d love to explore further. Could you elaborate more on next time? Also, if you have any recommended resources for further reading on this topic, I’d be grateful. Thanks for sharing your knowledge and contributing to a deeper understanding of this subject! I dedicated time to make a comment on this post immidiately after reading it, keep up the good work and i will be checking back again for more update. i appreciate the effort to write such a fantastic piece.
I absolutely love your blog and find a lot of your post’s to be what
precisely I’m looking for. Does one offer guest writers to write content for you?
I wouldn’t mind writing a post or elaborating on some of the subjects you write about here.
Again, awesome web log!
I know this if off topic but I’m looking into starting
my own blog and was wondering what all is needed to get set up?
I’m assuming having a blog like yours would cost a
pretty penny? I’m not very internet smart so I’m not 100% positive.
Any tips or advice would be greatly appreciated. Appreciate it
I’ve been surfing online more than 4 hours today, yet I never found
any interesting article like yours. It is pretty worth enough for me.
In my opinion, if all website owners and bloggers made good
content as you did, the internet will be a lot more useful than ever before.
Thankfulness to my father who shared with me on the topic of this blog,
this weblog is truly remarkable.
It’s actually a great and useful piece of information. I am happy that you simply shared this
useful information with us. Please stay us informed like this.
Thanks for sharing.
This article was a fantastic read! I appreciate the depth of information and the clear, concise way it was presented. It’s evident that a lot of research and expertise went into crafting this post, and it really shines through in the quality of the content. I particularly found the first and last sections to be incredibly insightful. It sparked a few thoughts and questions I’d love to explore further. Could you elaborate more on next time? Also, if you have any recommended resources for further reading on this topic, I’d be grateful. Thanks for sharing your knowledge and contributing to a deeper understanding of this subject! I dedicated time to make a comment on this post immidiately after reading it, keep up the good work and i will be checking back again for more update. i appreciate the effort to write such a fantastic piece.
Hello there! I know this is kinda off topic however
, I’d figured I’d ask. Would you be interested in exchanging links or
maybe guest authoring a blog post or vice-versa?
My website goes over a lot of the same subjects as yours and I believe
we could greatly benefit from each other. If you happen to
be interested feel free to send me an e-mail. I look forward to hearing from you!
Great blog by the way!
I think the admin of this web page is truly working hard in support of his web page, since here every material is quality based stuff.
I’m impressed, I have to admit. Rarely do I come across a blog that’s both equally educative and entertaining, and let
me tell you, you’ve hit the nail on the head.
The issue is something that not enough people are speaking
intelligently about. Now i’m very happy I came across this in my
search for something concerning this.
I always spent my half an hour to read this blog’s posts everyday along with a mug of coffee.
Hello there, just became aware of your blog through
Google, and found that it is truly informative.
I am going to watch out for brussels. I’ll appreciate if you
continue this in future. Many people will be benefited from
your writing. Cheers!
I was suggested this web site by my cousin. I
am not sure whether this post is written by him as nobody
else know such detailed about my difficulty. You are amazing!
Thanks!
I do not even know how I ended up here, but I thought this post was good.
I do not know who you are but definitely you’re going to a famous blogger if you are not
already 😉 Cheers!
It’s hard to find knowledgeable people about this subject, however, you sound like you know what you’re talking about!
Thanks