I’m building a browser extension that will insert a chunk of HTML into some pages. I’d like the page’s CSS to not apply to this section. What is the best way to do this? Is there a good reset I can put on the root element of my HTML and set it to !important so it gets applied after others?
Share
The only way to 100% take it out of the cascade is to put it inside an iframe.
You could use a css reset stylesheet but just prefix everything with your root element id/class. This would go a long way to combating the effects but in the field you will probably have to do some more final tweaks.
Probably the best approach would be to simply set every reasonable property of your sub-rules.
So what I mean is set the background, foreground, font, size, etc etc. Fully define the rules so that they say exactly what you want and don’t leave any space for the cascade to fill in defaults that you’re not interested in.