Until tonight, our web site has been serving up XHTML content with the
text/html MIME type. According to the XHTML spec, this is
acceptable, but others strongly disagree. I find the
arguments somewhat persuasive, particularly those related to the
"HTML-compatible" XHTML profile not really being HTML-compatible.
So, tonight I finally crossed another task off my list and implemented
the code to serve up appropriate content based on the HTTP Accept
header sent by the browser. If the browser says it can accept
application/xhtml+xml, then I send XHTML 1.0 Strict with the proper
content type (even if the browser prefers HTML; this might be a mild
HTTP violation, but I’m OK with that for now). If the browser does
not claim to accept application/xhtml+xml, then it re-renders the
page as HTML 4.01 and sends it as text/html. Since my server code
passes data through the rendering pathway as XML trees, it was not too
difficult to add a final post-processing step that converts an XML dom
to an HTML dom using Nethtml and then rendering that to the
browser.
Read more...