Introduction
One of the key problems developers face with CSS is styles leaking out to components they should not apply to. Developers h...
For further actions, you may consider blocking this person and/or reporting abuse
Really nice article, and also very complete, although some of the details like the
&
working like the scope root selector while:root
only selects the root specifically might be hard to understand when you don't already know them.One thing I'd add: it'll also be possible to scope styles in an
@import
statement and even in<link>
tags, although the details of this are still being discussed.github.com/w3c/csswg-drafts/issues...
I just remembered that I wrote my own article on scope a few years ago; it's not nearly as detailed as this one, but it mentions a few additional details about where this could be useful to add some more context:
dev.to/darkwiiplayer/what-is-css-s...
Very interesting! You can achieve the same thing much more succinctly, like this:
In that example, only
<p>
elements in an element with classbox
would be red, the rest would be the default color.This only works for the simplest cases. It doesn't consider scope proximity and, more importantly, doesn't let you define a lower boundary for the scope.
css scope is interesting. Haven't used it yet. thanks for sharing! i'll have to try it out.
Thank you for the feedback. You should try it out soon ☺️
Here is my full response. I tagged your post btw! dev.to/annavi11arrea1/styling-choi...
Thank you for the tag. I enjoyed reading your response 😊
Thank you!
I intend to! you sparked a train of thought and i am now writing LOL
Great post!
Thank you 😊