tl; dr: Use HTML5 because text / html XHTML is parsed as HTML5, and proper XHTML can crash effectively.
Browsers currently do not actually support HTML4 or XHTML / 1.x. They process all documents because HTML5 / XHTML5 (for example, <video>
will work even if you install HTML4 or XHTML / 1.x DOCTYPE).
Your choice is really not between HTML5 and XHTML, but between text/html
and XML
parsing modes and whimsical and standardization modes. Browser engines are not consistent with the W3C specification versions.
The real choice:
quirks vs standard mode . "Quirks" is an emulation of IE5 and field model errors. Quirks will bite if you do not put DOCTYPE
or use one of the deprecated DOCTYPE
(e.g. HTML4 Transitional).
The obvious choice is to include a standards mode by placing (any) modern DOCTYPE
in each document.
text/html
vs application/xhtml+xml
. XML mode allows you to use XHTML functions that were not in HTML (for example, namespaces and self-closing syntax for all elements), and, most importantly, allows you to work with a draft error. NB: It is not possible to enable XML mode from a document. The only way to enable this is through the actual Content-Type
HTTP header (for this purpose <meta>
and DOCTYPE
ignored!)
XML mode was supposed to be the best for mobile phones in the days 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 kind of proxy software used by major mobile operators, at least in the UK and Poland, where I tested it, which introduces invalid HTML to everything that looks HTML-like , including properly submitted XHTML documents.
This means that your well-formed, perfect XHTML will be destroyed along the way, and the user will see on his screen only an XML parsing error. The user will not be able to notify you of this problem, and since the markup is broken outside your server, this is not something you could fix.
The way all XML-mode pages (properly served by XHTML) look like O2 UK:
(the page displays perfectly when loading via Wi-Fi or VPN, which prevents the mobile operator from twisting the markup)
source share