It turns out that nobody knows how to use XHTML
The Surfin’ Safari blog has a post by maciej pointing out that most people use XHTML wrong, including (in particular) almost everyone that displays the “Valid XHTML 1.0″ logo on their websites.
So what really determines if a document is HTML or XHTML? The one and only thing that controls whether a document is HTML or XHTML is the MIME type. If the document is served with a text/html MIME type, it is treated as HTML. If it is served as application/xhtml+xml or text/xml, it gets treated as XHTML. In particular, none of the following things will cause your document to be treated as XHTML:
- Using an XHTML doctype declaration
- Putting an XML declaration at the top
- Using XHTML-specific syntax like self-closing tags
- Validating it as XHTML
In fact, the vast majority of supposedly XHTML documents on the internet are served as text/html. Which means they are not XHTML at all, but actually invalid HTML that’s getting by on the error handling of HTML parsers.
The article concludes by recommending, essentially, that you write HTML 4.01 code and serve it up as text/html. Controversial advice, given what the Web Standards crowd has been saying about XHTML for a while. In light of the above, XHTML seems worse than useless (for the next decade anyway) - it’s actually causing the very compatibility problems that the WaSP people are trying to prevent. I’m curious to know what people like Molly Holzschlag have to say about this.
The article is worth a read. Don’t give up on it because of it’s very introductory-level first paragraph.
No Responses to “It turns out that nobody knows how to use XHTML”
No comments yet