elehack.net

HTML is now really, really valid

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.

If you find any problems with the site after this, particularly in IE or other non-XHTML browsers, let me know.

Comments

No comments posted.

Post a Comment

You may post a comment using the form below. All fields are optional. By submitting a comment, you release it to Michael and Jennifer Ekstrand under the Creative Commons Attribution 3.0 license. See our copyright notice for details. You might also want to read our privacy statement.