xhtml Strict and inline styles

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

xhtml Strict and inline styles

Post by RSteinwand » Wed Jun 11, 2008 8:05 am

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
Site Admin
Posts: 3417
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Post by Albert Wiersch » Wed Jun 11, 2008 3:17 pm

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?
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Post by RSteinwand » Thu Jun 12, 2008 7:07 am

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
Site Admin
Posts: 3417
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Post by Albert Wiersch » Thu Jun 12, 2008 9:11 am

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.
Image
Albert Wiersch

Post Reply