Mobile: html5 vs xhtml

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

Any insight would be wonderful.

+3
source share
4 answers

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:

enter image description here

(the page displays perfectly when loading via Wi-Fi or VPN, which prevents the mobile operator from twisting the markup)

+3
source

HTML5 and XHTML are not exclusive. You can use both at the same time (XHTML 5), or you cannot use either (HTML 4).

I would not write documents in [X] HTML5 until the standard is finished, not to mention any implementations. The β€œHTML5” features available in some browsers are usually script extensions that do not affect HTML at the markup level at all.

+2
source

I understand that neither iPhone nor Blackberry fully supports HTML 5. Therefore, if you do not need specific HTML 5 features, I would stick with XHTML.

+1
source

Choose any of them. XHTML is just serialization of HTML in XML, so it’s actually just DOM nodes encoded differently. (Maybe I can create a JSON-serialized version of HTML?) Indeed, the choice of serializing SGML or XML depends on whether this device supports it. Apple uses WebKit, which fully supports XHTML.

Remember to send XHTML as application / xhtml + xml or it will not be considered as XHTML!

Oh ... and one more thing. All browsers that I know about XHTML support except IE.

0
source

Source: https://habr.com/ru/post/1414974/


All Articles