I've started looking at serving XHTML documents as application/xhtml+xml to user agents that support it, and as text/html to the rest. It occurred to me that when using internal CSS (defined in a style element), enclosing the CSS in HTML style comments (<!-- ... -->) to hide it from browsers which don't support CSS will also hide it from browsers like Mozilla and Opera when the document is served as application/xhtml+xml. Correct behaviour, but in most cases not what you want. The article Properly Using CSS and JavaScript in XHTML Documents [1] at Netscape Devedge recommends that all CSS is moved to external files when using XHTML. That's what I do most of the time, but in some cases there are reasons for using internal CSS.
I then found this in Ian Hickson's Sending XHTML as text/html Considered Harmful [2]:
"To embed CSS in an XHTML document which may be handled as either HTML4 or XHTML, you have to use:
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
...
/*]]>*/--></style>"
That makes Mozilla apply the rules, and the W3C validator does not find any problems. Opera (7.52), however, does not apply the CSS.
Anyway, I was wondering if, and how, other people hide internal CSS in XHTML documents from user agents that don't support CSS. Note that this is about cases when moving the CSS to an external file is not an option, for whatever reason.
[1] < http://devedge.netscape.com/viewsource/2003/xhtml-style-script/ > [2] < http://www.hixie.ch/advocacy/xhtml >
/Roger
-- http://www.456bereastreet.com/
*****************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
*****************************************************
