Serving page as text/html

This page was served as text/html. No problem here.

(But it’s XHTML — the doctype and meta tags say so! Well, not really. Go ahead, click on Tools>Page Info and see the type the page was served up as under the General tab. I’m assuming you’re using Mozilla/Firefox, or what’s the point?)

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.

See the xhtml+xml page in action.

SIIR Test: About