Live data from Hacker News

Inline Scope for CSS

picostitch.com

41–43 of 43 posts

Re: Inline Scope for CSS

#41
post #40
post #37

Earlier quoted context omitted.

I know people get incredibly upset whenever this gets mentioned because suddenly they DO want it again but that was a big part of what “web components” were. When you need that level of isolation you can get it for free without any extra work.

Web Components are doing much more with isolation than just isolating styles. You don't want/need to kill your a11y, form participation, and a bunch of other things (and laboriously solve them with Javascript) just because you want to scope your styles

Form participation has been fixed for a while now for the record.

Re: Inline Scope for CSS

#42
post #41
post #40

Earlier quoted context omitted.

Web Components are doing much more with isolation than just isolating styles. You don't want/need to kill your a11y, form participation, and a bunch of other things (and laboriously solve them with Javascript) just because you want to scope your styles

Form participation has been fixed for a while now for the record.

Yes, you have to manually set it up with javascript, or use a lib/framework that solves it for you automatically.

Too much hassle when all you need is style scoping

Re: Inline Scope for CSS

#43
post #18
post #9

For now, as Firefox support is not yet good, We can use nested rules in CSS. HTML: This is a paragraph CSS: my-custom-element { p { color: blue; } } By choosing a unique name for the custom element, we achieve near the same functionality as @scope.

Is this not the same as having a class with a unique name, and applying it to a parent div

Quite the same if you use nested css on the div.class-name-here. The diff is in the semantic. My post was about using nested CSS to "emulate" @scope
Post reply on HN