For an XHTML page to be valid, it should of course, validate. (Funny sentence! <g>)
An oft-forgotten rule though is that XHTML documents are XML documents, and because of that, they must be served using the mime-type application/xhtml+xml
. Internet Explorer predictably, chokes on this, therefore, you need some selective magic to accomplish this. If you’ve got PHP on your webserver, the following script will do the deed:
/*Send application/xhtml+xml to compliant browsers, text/html to others*/
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml; charset=utf-8");
print "< "."?xml version=\"1.0\" encoding=\"UTF-8\"?".">";
}
else {
header("Content-type: text/html; charset=utf-8");
}
Leave a Reply