HTML 5 + XML = XHTML 5

(Also available in Spanish Traducción de “HTML 5 + XML = XHTML 5″ and Portuguese.)

I like the xhtml syntax. It’s how I learned. I’m used to lowercase code, quoted attributes and trailing slashes on elements like br and img. They make me feel nice and comfy, like a cup of Ovaltine and The Evil Dead on the telly.

But you might not. You might want SHOUTY UPPERCASE tags, no trailing slashes and attribute minimisation. And, in HTML 5, you can choose.

Thanks to the “pave the cowpaths” principle, it’s up to you. As you like it. What you will. Whatever you want, whatever you like.

But let no-one tell you that HTML 5 kills XML—meet XHTML 5.

XHTML 5 is the XML serialisation of HTML 5 and, as you’d imagine, it has all the stricter parsing rules that you’d expect (and are used to if, like me, you grew up with XHTML DOCTYPES). It must be served with an XML MIME type, such as application/xml or application/xhtml+xml (so no rendering in Internet Explorer for the moment) and will throw a wobbly at the slightest well-formedness violation. (See Serving XHTML with the Right MIME Type for more information.)

Usual XML rules apply: no document.writes allowed, no DOCTYPE required, some syntax and script differences to trip up the unwary and you can use namespaces.

The main differences are summarised on the official WHATWG wiki Differences Between HTML and XHTML. It’s also possible to write polyglot documents that can be processed as either by browsers, depending on the MIME type used.

Magne emailed the Doctor to ask “Is it OK to use HTML5 tags in a page with the XHTML 1.1 doctype? Which one should I use, as in, which one is the recommendation now?”

If you want to use the new features, you need to use HTML 5 DOCTYPE or XHTML 5. Given that Internet Explorer cannot process XML, for pragmatic reasons the Doctor advises HTML 5.

Share and Save:
  • Twitter
  • Digg
  • Sphinn
  • Reddit
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Netvibes
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • HackerNews
  • LinkedIn
  • NewsVine
  • Tumblr

This article was written by Bruce Lawson. Bruce evangelises Open Web Standards for Opera. He's a member of the Web Standards Project's Accessibility Task Force and the W3C Mobile Best Practices Working Group. Previously, he was technical lead for the Solicitors Regulation Authority site. He's been a tarot card reader in Istanbul, a volunteer pharmacist in Calcutta, a Bollywood movie extra in Mumbai and English tutor to a Princess' daughter in Thailand. Nowadays, he blogs at www.brucelawson.co.uk, is training for his blue belt in kickboxing and drinks too much Guinness.

Posted on

Got anything to add or ask? then leave a response,
or trackback from your own site.

Categorised under: Attributes, Browser Compatibility, Structure.

Tagged with: , , .