Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which MIME type should I use to serve XHTML5 to IE7 and IE8?

I want to use XHTML5 but apparently they two browsers don't accept the application/xhtml+xml MIME type. I read that they will accept text/xml (or application/xml not sure) but it is kind of hackish. So I was wondering if I should just serve HTML5 to IE7 and IE8?

Please don't go on talking about XHTML vs HTML advantages. I know.

like image 494
user434366 Avatar asked Dec 17 '25 19:12

user434366


2 Answers

XHTML 5 is not a standard. XHTML 2 does prescribe a new doctype, though XHTML 2 is not supported by any modern browsers (as it is largely unfinished).

HTML5Doctor recommends that if targeting an "XHTML5" approach, simply use the HTML5 doctype, which makes sense. The HTML5 doctype is compatible with IE7/8.

http://html5doctor.com/html-5-xml-xhtml-5/

Remember, to use HTML5 (properly) in IE <9, you need to include the HTML 5 shiv.

http://ejohn.org/blog/html5-shiv/

Also, in terms of a MIME type for XHTML5, you MUST serve the content with application/xhtml+xml or application/xml, which older version of IE will NOT support. Thus, if you're trying to take a purist approach, you CANNOT have IE 6/7 support.

like image 58
mattbasta Avatar answered Dec 19 '25 09:12

mattbasta


My split-the-difference recommendation:

  • On the server, use an XML-based processing pipeline.
  • But right before you emit the HTTP response body, convert to the HTML5 serialization.
    • That means <!doctype html> and no <?xml ...?> nor xmlns directives.
  • Serve your pages with Content-Type: text/html; charset=utf-8. (Change the value of the charset parameter if you must, but PUT ONE IN, or you risk UTF-7 trickery.)
  • Don't try to condition any of this on the user-agent.

You get the benefits of XML strictness on the server -- you'll notice if you're generating invalid markup, and it makes it much harder to get quoting wrong -- but you don't have to deal with figuring out which clients will actually honor XML mime types.

Note that you can directly embed SVG and MathML in HTML5 even when you're using the HTML5 serialization (the <svg> and <math> elements are magic).

like image 41
zwol Avatar answered Dec 19 '25 07:12

zwol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!