3

I am building a mobile app (hybrid mobile web app but with a native shell) with most users on the iphone (some on the blackberry) and am wondering if it should be written in html5 or xhtml?

Any insight would be great.

4 Answers4

3

tl;dr: Use HTML5, because text/html XHTML is parsed as HTML5, and proper XHTML can fail spectacularly.


Current browsers don't actually support HTML4 or XHTML/1.x any more. They treat all documents as HTML5/XHTML5 (e.g. <video> will work even if you set HTML4 or XHTML/1.x DOCTYPE).

Your choice isn't really between HTML5 and XHTML, but between text/html and XML parsing mode and quirks and standards rendering modes. Browser engines are not aligned with versions of W3C specs.

The real choices are:

  1. quirks vs standards mode. "Quirks" is emulation of IE5 bugs and box model. Quirks bites if you fail to put DOCTYPE or use one of obsolete DOCTYPEs (like HTML4 Transitional).
    The obvious choice is to enable standards mode by putting (any) modern DOCTYPE in every document.

  2. text/html vs application/xhtml+xml. The XML mode enables XHTML features that weren't in HTML (such as namespaces and self-closing syntax on all elements) and most importantly enables draconian error handling.
    NB: it's not possible to enable XML mode from within a document. The only way to enable it is via real Content-Type HTTP header (for this purpose <meta> and DOCTYPE are ignored!)

The XML mode was supposed to be the best for mobiles in times of WAP and XHTML Basic, but in practice it turned out to be a fantasy!

If you use application/xhtml+xml mode your page will be completely inaccessible to many users of GSM connections!

There's some proxy software used by major mobile operators, at least in UK and Poland where I've tested it, which injects invalid HTML to everything that looks HTML-like, including properly served XHTML documents.

This means that your well-formed perfect XHTML will be destroyed in transit and user will see only XML parse error on their side. User won't be able to notify you about the problem, and since markup is malformed outside your server, it isn't something you could fix.

That's how all XML-mode (correctly served XHTML) pages look like on O2 UK:

enter image description here

(the page renders fine when loaded via Wi-Fi or VPN that prevents mobile operator from screwing up the markup)

Kornel
  • 97,764
  • 37
  • 219
  • 309
2

HTML5 and XHTML are not exclusive choices. You can use both at once (XHTML 5) or you can use neither (HTML 4).

I wouldn't author documents to [X]HTML5 yet as the standard is not yet finished, never mind any implementations. The “HTML5” features we have available in some browsers are generally scripting extensions that don't affect HTML at a markup level at all.

bobince
  • 528,062
  • 107
  • 651
  • 834
1

My understanding is that neither the iPhone nor the Blackberry fully support HTML 5 yet. So unless you need some specific HTML 5 features I would stick with XHTML.

ctford
  • 7,189
  • 4
  • 34
  • 51
0

Pick any of them. XHTML is just an XML-language serialisation of HTML, so in reality, it's just DOM nodes encoded in a different way. (Maybe I could create a JSON-serialised version of HTML?) Really, the choice of SGML or XML serialisation depends on whether or not the device supports it. Apple uses WebKit, which fully supports XHTML.

Remember to send your XHTML as application/xhtml+xml or it won't be treated as XHTML!

Oh... and one other thing. All browsers that I know of support XHTML except IE.

Delan Azabani
  • 79,602
  • 28
  • 170
  • 210