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.

4 Responses to “Serving XHTML as application/xhtml+xml”

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

  2. 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");
    }
    else
    {
    header("Content-Type: text/html; charset=UTF-8");
    }
    ?>

Comments closed, if you feel you have something to say:
drop me a line.