Hacker News new | ask | show | jobs
by nostrademons 3888 days ago
You're looking for "<style scoped>", which is in Firefox, used to be in Chrome, but was eventually removed in favor of Shadow DOM.

http://html5doctor.com/the-scoped-attribute/

http://caniuse.com/#feat=style-scoped

https://groups.google.com/a/chromium.org/forum/#!searchin/bl...

I think the main reason webcomponents won out over scoped styles is because usually once you need to scope your styles, you find you also need to scope your querySelector calls, and your DOM traversals, and your IDs....and pretty soon you have shadow DOM. It's unlikely that you need style namespacing if you're just a single dev working on a static page, and it's unlikely that you won't need JS & DOM scoping if your product grows beyond that.