xhtml Strict and inline styles

For topics about current BETA or future releases, including feature requests.
User avatar
RSteinwand
Rank VI - Professional
Posts: 596
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

xhtml Strict and inline styles

Post by RSteinwand »

Also from devedge-temp.mozilla.org, they recommend delimiting inline styles for both text/html and text/xml like this:

<style type="text/css">
<!--
#main{text-align:left}
-->
</style>

Which you flag with this error:
"In XHTML documents, style and script content must not be in a comment because it technically means that the browser will see it as a comment and not as actual style or script content (though browsers are currently forgiving about this). However, not using comments makes your document less compatible with pre HTML 3.2 browsers (but most browsers now in use are HTML 3.2+ compatible). For maximum compatibility, consider putting the style information in an external style sheet. The next best option for XHTML documents is to not put the style information in a comment because this is technically not what you want even though it may work with today's browsers."
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Post by Albert Wiersch »

Thanks. I read that article and it seems that they recommend external files. I don't see them recommending to comment out style and script information in XHTML documents. If an XHTML document is correctly treated as XHTML, then any commented out style and script content will be ignored.

I think the error message that CSE HTML Validator is generating for XHTML documents is a good one. Am I missing something?
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
RSteinwand
Rank VI - Professional
Posts: 596
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Post by RSteinwand »

If you go down to the section entitled "Using CSS rules in inline style within comments", click on example 1 and 2 and view the source. They treat css like I posted above for text/html and text/xml.

External files aren't an option for me if I'm tweaking something for one page and it's 2 or 3 items. I'd have to have 30 more css files.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Post by Albert Wiersch »

RSteinwand wrote:If you go down to the section entitled "Using CSS rules in inline style within comments", click on example 1 and 2 and view the source. They treat css like I posted above for text/html and text/xml.
Yes, I see that. Notice how it doesn't work for example 2 because it is served as text/xml and thus treated as XML (I checked in IE, Firefox, and Opera). The commented out CSS works in the first example because it is served as text/html and thus not interpreted as XHTML/XML.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial