Tuesday 14 July 2009

HTML5 & XHTML5: MIME is The Answer

Currently, all the HTML5 / XML “serialization” stuff simply boils down to two straight-forward rules:

  1. If HTML5 using HTML syntax is served with MIME type text/html This is HTML serialization.
  2. If HTML5 using XML syntax is served with MIME type application/xhtml+xml then this is XML.

Disclaimer on all things series 5: I might be wrong now. Then again, I might be right in five minutes.

Filed under:   general
Posted by:   Molly | 04:18 | Comments (16)

Comments (16)

  1. Stupid question time…


    Carolyn Ann

  2. I meant to add a “ps”. I missed you and your words, Molly! 🙂

  3. Hehe, Carolyn Ann – because they could? It’s odd to me too. One thing I’m certain about is that calling it XHTML5 (the XML serialization of HTML5) is just beyond confusing on top of a “monolithic lump” of other confusing stuff.

  4. Doesn’t it get even more confusing because what we think of as xml syntax, closing slashes on br for example, is valid HTML5 syntax. For example, you can take a valid XHTML 1 Strict page, change the doctype and have it validate as HTML5.

  5. Is there an XHTML5 validator, and is this right?

  6. Well, it seems this time the standards body (W3) adds to the confusion instead of defining a clear specification. Well done!

    Maybe someone can make an official statement? Something like ‘because so much people are used to it we provided two doctypes, but hey, the specs on both are the same so it really doesn’t matter which one you use. Serve it as you like it, but shut up.. please!’

    But no, there is a trench war going on that started back in 1998.
    Q: How productive is this?
    A: Not at all

    Q: Are there some big men with little willies at war?
    A: You bet!

  7. @Joel, yes the W3C validator has “experimental” support for HTML5; not sure if it will detect by doctype or if it has to be manually selected though, as I have yet to write my first HTML5.

  8. And what if I save an xhtml5 page to the hard disk and open it? Is is parsed as xhtml then? The hard disk does not send any headers, you know.

  9. SpShut: on the local file system, it depends on the OS. On Windows, a file with extension .xml or .xht or .xhtml will be XML and a file with extension .htm or .html will be HTML. I think on Mac OS X and Linux, files can be of a certain type without a file extension.

  10. As well, you can set the mime type in a meta tag.

  11. Is a document using HTML 5 with all the self-closing XML syntax served with text/html media type HTML5 or XHTML5?

    • Bascially its HTML5. As far as I can gather both unclosed and self-closing tags seem to be valid HTML syntax though I could be wrong.

  12. @draco – The MIME type is set by the server, and sent to the browser in the document header. Many, but not all, send files named with suffix ‘.xml’ and ‘.xhtml’ as some flavor of xml. You can likely change this with your .htaccess file.

    For local files, see zcorpan’s reply (No. 9)

  13. Sounds straightforward enough to me.

    Hey, love the disclaimer too!! 😉

Upcoming Travels