Why using text/html for XHTML is bad
Edit by Megan:
This content was scraped from Ian Hickson's landmark article Sending XHTML as text/html Considered Harmful
I have left this topic open because it is an interesting issue to discuss.
Please do not scrape content from other sites to post here. That's just lame.
webwiz posted this at 02:49 — 1st December 2007.
He has: 629 posts
Joined: May 2007
An interesting topic, yes. An old one, as well !
Harmful or not, I'd guess some 99% or more "webmasters" have no idea that their lovely XHTML code is interpreted as HTML by every browser on earth, with no benefit from all the XML goodness promised by XHTML evangelists.
It has to do with MIME types. While the file name ends in .htm, .html, ,php, or similar, nearly every host will send the document as MIME type text/html. The .php does not work from a hard drive, but the usual setup for files on the hard drive treats .htm and .html as MIME type text/html as well. Not a trace of "eXtensible" markup anywhere.
Generally speaking, but not universally true, if you add the <?xml declaration to the beginning of your validating XHTML document, then rename it with a .xhtml extension, it is likely that it will be treated as genuine XHTML. Not guaranteed, but worth a try.
Any road up, (mis)using XHTML markup as faux HTML has not broken the web yet. I think that Hickson rather overstates his case.
Anyone out there with another experience / point of view?
Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.