[ This a draft Ask the W3C answer for review ]

A MIME type defines the type of file. Each file has a specific MIME type constructed of two parts: the main type and a subtype. The two parts are separated by a slash "/". It indicates the user agent receiving the document how to handle it and apply a particular treatment. It means also that you can attach a particular application to a particular MIME type in your browser.

What mime-type should XHTML be served with?

The short answer is application/xhtml+xml, as described by the XHTML Media-types Note. But the long answer adds some important modulations.

Why not text/html?

text/html has been historically the mime-type associated with HTML, so why is there a new mime-type for XHTML? The first reason is that XHTML is not HTML: there are for instance some important syntax differences, the biggest one being that empty tags such as <br> must not be closed in HTML whereas they must be ( la <br/>) in XHTML.

Another good reason to use a new mime-type for XHTML is that it is an XML languages, which means that it has stricter rules checking and hence has better chances to avoid the infamous tag soup that too many people have called HTML, and that browsers will be able to handle faster the resulting code.

But some browsers don't know about application/xhtml+xml.

Indeed, and that's one of the biggest issue with the adoption of the new mime-type nowadays, especially since Internet Explorer doesn't recognize it (at least for any version up to 6.x on both Windows and Mac). Of course, this is a usual problem with adoption of new technologies and it usually gets better with time, but for the time being, there are ways out of this vicious circle:

The first technique makes your content understandable to the vast majority of web browsers, but doing so, you loose all the advantages of a different MIME-type: advertising XML conformance, distinguishing from tag soup, getting fast track rendering on modern browsers.

The second technique has probably the best coverage of existing browsers while keeping the new MIME-type for those able to understand it; the downside is that it can be quite tricky to implement on your site, depending on how much access you have to its settings.

Note that you can alternatively serve your XHTML (any version) as application/xml (or text/xml, but this MIME-type is harder to get right with regard to encoding), but I.E. will display it as source code instead of XHTML.

How do I set up the content-negotiation you're speaking about?

This depends on the web server you're using: if you're not the administrator of the web server where you want to use this content negotiation, point your web server administrator to this document and ask him to set it as needed for you.

If you're the administrator of the web server in question, you can have a look at the linked techniques for your web server, or even better, send us the techniques you know for it.

To sum up

Let's try to summarize what we've just exposed:

(X)HTML version Recommended MIME-type Limitations in browser Alternate MIME-types Techniques
HTML 2.0,3.2,4.0,4.01 text/html none, but this MIME-type has been abused very often as an umbrella for tag soup N/A N/A
XHTML 1.0 application/xhtml+xml Not recognized by Internet Explorer 6.x and previous versions
  • if using the backward compatibility guidelines, text/html
  • application/xml (or text/xml, but with much caution with regard to charset setting)
XHTML 1.1, XHTML Basic, XHTML profiles application/xhtml+xml Not recognized by Internet Explorer 6.x and previous versions
  • application/xml (or text/xml, but with much caution with regard to charset setting)
serving as text/xml for I.E.