Is there any way to access an external CSS from the body? Or, change the CSS for the entire document just using things within the body tag? I think there may be a JavaScript solution; I also asked in the JavaScript forum.Hmm... I'm not sure I totally understand. Forgive me for asking, but why would you want an external CSS file in the body anyway? Inserting CSS into your <head> would affect your entire document, and trying to insert it into your <body> would be pointless.You can swap style sheets (<!-- m --><a class="postlink" href="http://www.alistapart.com/articles/bodyswitchers/">http://www.alistapart.com/articles/bodyswitchers/</a><!-- m -->), change rules, selectors or values. What do you want to do?I think all references to external style sheets have to be done in the head.Uh, thanks Fang. That helped a lot! Forgive me for asking, but why would you want an external CSS file in the body anyway?
Forgive me for answering, but I can think of several reasons, the most obvious of which being if you wanted styles localized to a small section of a document. For example, external content such as advertising or a feed.
It would be tremendously useful to be able to insert a <style> block and have the styles be active only until the current scope ends.
These objectives can be accomplished by 'phoning ahead' to find out what the ad-styles are, but most archaic CMSes weren't built with that in mind.It would be tremendously useful to be able to insert a <style> block and have the styles be active only until the current scope ends.
I suppose, but can't that be done using <div></div>?I suppose, but can't that be done using <div></div>?
Only inline. He'd like to do an external at that point.If you want to style a specific part of a page differently then you would simply encompass it in a DIV, and then include the styles for that section in the external (or inline, if you prefer) stylesheet using CSS selectors to apply the style only to the content of that DIV.
Of course, this has nothing to do with changing styles on the fly, which is what moku was asking.
To do this, I would typically create several classes with the different styles and switch them with javascript using object.className. I produced my fading DHTML menu this way because I was not sure how to adjust CSS opacity via the DOM.
Forgive me for answering, but I can think of several reasons, the most obvious of which being if you wanted styles localized to a small section of a document. For example, external content such as advertising or a feed.
It would be tremendously useful to be able to insert a <style> block and have the styles be active only until the current scope ends.
These objectives can be accomplished by 'phoning ahead' to find out what the ad-styles are, but most archaic CMSes weren't built with that in mind.It would be tremendously useful to be able to insert a <style> block and have the styles be active only until the current scope ends.
I suppose, but can't that be done using <div></div>?I suppose, but can't that be done using <div></div>?
Only inline. He'd like to do an external at that point.If you want to style a specific part of a page differently then you would simply encompass it in a DIV, and then include the styles for that section in the external (or inline, if you prefer) stylesheet using CSS selectors to apply the style only to the content of that DIV.
Of course, this has nothing to do with changing styles on the fly, which is what moku was asking.
To do this, I would typically create several classes with the different styles and switch them with javascript using object.className. I produced my fading DHTML menu this way because I was not sure how to adjust CSS opacity via the DOM.