So basically I have a page that has it’s own CSS. On my server I have a folder of different CSS style files, so I want to have a “preview” window on my page for them. Can I somehow, maybe using javascript, apply an external CSS file only to a certain DIV, not to the entire page so I can get a “preview” of the custom CSS file? I’d rather not use iframes.
Share
CSS applies to entire documents.
If you want to limit the scope, then you need to make use of a descendent selector.
e.g.
#id_of_div .the .rest .of .the .selector {}You have to apply this to every selector, and take into account groups (so it isn’t as simple as just prefixing the whole stylesheet and suffixing every
})You would also find the stylesheet for the main document applying to your preview.
A frame would probably be the best approach to solving this problem.