Serving XHTML 1.1


 

The W3C used to state that XHTML 1.1 should be served as MIME type "application/xhtml+xml" and not as "text/html" - ref, the W3C Note: *XHTML Media Types - Summary. Since the issue of the updated Note *XHTML Media Types - Second Edition in January 2009, however, this restriction has been removed and, provided that certain *Compatibility Guidelines are followed, you can now serve XHTML 1.1 documents as "text/html". Excellent! Bear in mind, however, that this W3C Note is still described only as a work in progress. Also, I have to say that I do not myself follow the first of these guidelines since I tend to include the XML declaration even in "text/html" documents - see The XML Declaration and DOCTYPE Sniffing.

If you do serve an XHTML 1.1 document as MIME type "application/xhtml+xml", however, you should bear in mind that some browsers do not support this MIME type, most notably all current versions of Internet Explorer (IE) - that is IE8 and below.

Here at www.webcompliant.co.uk, we used to use content negotiation to serve XHTML 1.1 as "application/xhtml+xml" to browsers which prefer it and compliant XHTML 1.0 as "text/html" to the rest. Now, however, there is no content negotiation and all pages are written in HTML-compatible XHTML 1.1 and served as "text/html". This is somewhat against the W3C's guidelines in the above-mentioned Note (see: *Recommended Media Type Usage) which recommend that content negotiation be used to serve the document as different MIME types depending upon the user agent's HTTP Accept header. I have taken a different approach on this site, which allows the user more control over what they receive:
You can, if you wish, receive exactly the same documents served as "application/xhtml+xml" by changing the domain from www.webcompliant.co.uk to xhtml.webcompliant.co.uk in the URI. Conversely, if you are currently viewing an xhtml.webcompliant.co.uk URI, changing the domain to www.webcompliant.co.uk will revert you back to the "text/html" Content-Type. This seems like an ideal solution for a website such as this, which is aimed at web professionals.

Advantages of XHTML

  1. Since XHTML is a flavour of XML, it can be included within other XML documents and, similarly, other flavours of XML (e.g. *MathML, *SVG) may be included in an XHTML document - see, for example, the W3C Working Draft *An XHTML + MathML + SVG Profile (XHTML as the Host Language).
  2. XHTML can use *XSLT.
  3. When XHTML is served as "application/xhtml+xml" any well-formedness error within the page is fatal and the page cannot be displayed. This means that it is trivial to catch such errors and ensure that a page is well-formed. (Of course, this can also be a disadvantage, depending on your point of view!)
    Note: Since most user agents check "application/xhtml+xml" documents just for well-formedness, and not for validity with respect to the DTD, any validity errors (e.g. undeclared attributes, invalid attribute values or departure from declared Element Content Models) will not be evident. Pages should be subjected to W3C Validation in order to detect such errors.

Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 16 May 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Basics > Serving XHTML 1.1