This page was served as text/html. So far, so good.
(But the doctype and the meta tags say the page is XHTML! Well, they do. But the way it works is, the server sends a page with the MIME type in the Content-type HTTP header before it sends the content, and no doctype and meta declarations on our part can override that. In this case, the server should have sent application/xhtml+xml in the header, but since XHTML1.1 and below are “HTML-compatible” XHTML, it may also be served as text/html, and that’s exactly what the server did, doctype be damned. This I learned from Mark Pilgrim.)
So what happens when the page is served as application/xhtml+xml? To find out, we paste this code at the top of our test document, before the doctype tag:
<?
if (isset($_SERVER["HTTP_ACCEPT"]) && stristr($_SERVER["HTTP_ACCEPT"], 'application/xhtml+xml')) {
header('Content-Type: application/xhtml+xml; charset=ISO-8859-1');
} else {
header('Content-Type: text/html; charset=ISO-8859-1');
}
?>
With this piece of code, the browser “tells” the server whether it accepts application/xhtml+xml in the HTTP_ACCEPT header, and to serve the requested page as such.
If you’re using Mozilla/Firefox, see the xhtml+xml page in action.
DTR Test: About