Serving XHTML as application/xhtml+xml

When you’re coding XHTML, you should deliver it as application/xhtml+xml. The problem is however, that once you do that, IE 6 & 7 break horribly… For your pages to render properly in those browsers, you’d need to set the mime type to text/html. Some very bright people have thought this problem in the past and came up with a real good solution in PHP, which you can find here: serving up XHTML with the correct MIME type.

WordPress though is always served as XHTML, so if possible, it should send the proper MIME type. I wrote a small plugin that does that: XHTML MIME type plugin. It doesn’t work on this blog yet because of some modifications I’ve done, but I’ll try to get it working.

Tags: runs on the Genesis Framework

Genesis theme frameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides you with the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Read our Genesis review or get Genesis now!

4 Responses

  1. Krijn HoetmerBy Krijn Hoetmer on 24 April, 2007

    Right.. So when are you going to write an HTML5 plugin? ;-)

  2. Joost de ValkBy Joost de Valk on 25 April, 2007

    Hehe, not any time soon I guess :P

  3. Rogier SchoenmakerBy Rogier Schoenmaker on 18 May, 2007

    Lately I’ve been searching for an solution to the application/xhtml+xml problem in IE too. I found a lot of sites like the one you link to, with complex checks.
    First I had some troubles on understanding all these checks and I builded an easier one myself, which is included below, until I just saw your link. Some searching after that I found out that it was meant to sniff for browsers q-rating.
    This didn’t change my opinion that these checks are unnecessary complex. My checks work good in modern versions of Firefox, Opera and Netscape and it servers text/html nicely to IE. The only really problem I read about was for inline in Opera 7.x. As I’m not intending to use this, I don’t see any problem with my little script :)

    If there’s something I’ve missed, I’d gladly hear back from you guys ;)

    ‘ . “\n”);
    header(“Content-Type: text/html; charset=UTF-8″);

  4. Rogier SchoenmakerBy Rogier Schoenmaker on 18 May, 2007