Apply an external style sheet to a specific section

On my website I can use custom style sheets. But I do not want these styles to affect the whole site, just a separate section / div. Is there a way to do this without having to go through the entire user style sheet and adding my div selector to each css rule? For example, if the user has:

a, span{color:white;}
div{padding:10px;}

Now I have to disassemble it and replace it with

#mySection a, #mySection span{color:white;}
#mySection div{padding:10px;}
+3
source share
1 answer

No, unfortunately, no. CSS is not equivalent to a tag <base>or similar, which would limit the scope of the CSS rule.

You will need to add each rule using the element (s) to which you want to apply them, or load custom content into an iframe.

+7
source

All Articles