The Internet has undergone many transformations over the past decade, and with w3c's Web Standards Specifications, an initiative to modularize markup and expand accessability and forward-compatibility, for browsers, and languages to come. (Note: Legacy browsers [Eg. Internet Explorer 7 and below] will eventually be depreciated, to make new browsers more compliant with these standards)
Along with these new specifications, comes the confusion of multiple !DOCTYPE'S and MIME types. When creating an XHTML valid page, you must use XML-valid definitions, including defining a !DOCTYPE, and the corresponding MIME type must be used. If this is not the case, the document will not be considered "well formed", and will thus be treated as HTML, or tag soup NOTE: This does not mean it is tag soup. What is tag soup?
Sending XHTML 1.1 as text/html is NEVER fine. There is no spec that allows this. Sending XHTML 2.0 as anything in a production (non-testing) context is NEVER fine either, since that spec has not reached CR yet.
Sending XHTML 1.1 as text/html is considered to be "non-standards compliant", by all standards. Using XHTML 2.0 in a non-testing environment is forbidden, as it has not yet reached a controlled release or conformed release, where all browsers are released as standards-compliant. The solution is to send application/xhtml+xml to the MIME Content-type, using .htaccess.
Serving up a document containing what is to all intents and purposes XHTML as text/html simply means that browsers will jump into error correcting mode and deal. Serving the same document as application/xhtml+xml will, in most cases, present the user with a download dialogue of some sort.
However, this solution does cause problems in Internet Explorer, all versions, up to and including 8. When pages with the
The most-used attribute on html elements is xmlns, from misguided people using XHTML but sending it as text/html. They even (just) outnumber the people who specify the lang attribute!
This quote from Google's own Web Stats site gives us a visual approach to showing the MOST common approaches of web design, including (Correct and incorrect usages explained):
- How many elements do Web pages typically have?
- Most used tages/elements
- Most common attributes used
- META data
- Much more
Googles web stats resource shows how/why the w3c-standards were developed, through rigerous analysis of content usage, and web browsing evolution. X/HTML5 is being developed with these figures in mind.
Conclusion
HTML5 doctype is simple, and backwards compatible with previous versions. It can produce valid code, and can be used to-date. XHTML has a few "quirks" which need to be worked out, but are not major problems for the average joe. The biggest tip I can give to any junior web developer is:
- Do your research, for YOUR specific needs
- Take note of versions, dates, time periods of documents to insure validity
- When in doubt, use a controlled release, or stable release (ie HTML 4.01)

No comments:
Post a Comment