tne
tne

Reputation: 7261

Is HTML4 forward-compatible with HTML5?

From the perspective of authors/servers, is HTML4 forward-compatible with W3C HTML5? Or, from the perspective of HTML engine developers/clients, is W3C HTML5 backward-compatible with HTML4?

I realize the intuitive answer is yes, but I found that this intuition often comes because almost all browsers support both HTML4 and HTML5 features. HTML5 deprecates a few things, so I would imagine that a user agent that only supports HTML5 (no concept of any other doctype) would have some trouble with HTML4-specific things.

So, another way of phrasing the question is: does the HTML5 spec cover everything HTML4 covers, and does it require implementations to degrade in a specified, defined or implementation-defined way when encountering an obsolete feature? Are these ways generally believed to guarantee that HTML4 documents be usable? (As in, not just requiring implementations to error-out or ignore things too much.)

Upvotes: 1

Views: 2191

Answers (3)

Kornel
Kornel

Reputation: 100110

does the HTML5 spec cover everything HTML4 covers, and does it require implementations to degrade in a specified, defined or implementation-defined way when encountering an obsolete feature?

Essentially, yes. Covers everything that's needed from HTML4, and all previous versions, even exotic things like <xmp> and <plaintext>.

Current browsers don't actually support HTML4 specifically, they interpret HTML4 documents as HTML5 with various levels of backward-compatibility quirks.

There are several document modes, such as quirks/almost standards/standards and HTML/XML modes, but there is no division along HTML4/HTML5 line (e.g. HTML4 with full Strict DOCTYPE gets same treatment as proper HTML5). <video> will work even if you label your document HTML2.0, and <isindex> will work even if you use HTML5 DOCTYPE.

Although HTML5 makes some HTML4 elements non-conforming, it still defines them, and still requires browsers to support them (HTML5 requirements for authors are different than HTML5 requirements for browser vendors):

http://www.whatwg.org/specs/web-apps/current-work/multipage/obsolete.html

HTML5 is intended to be fully backwards-compatible with HTML4-as-used-on-the-web, and deliberately ignores theoretical aspects of HTML4 spec, e.g. it's more compatible with IE6's HTML tagsoup parser than SGML syntax HTML4 was supposed to have — because that's what most websites on the web are actually compatible with.

Upvotes: 0

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201568

No, an HTML 4 document is in general not a valid HTML5 document. The answer is the same for HTML 4 Strict documents, though for it, the incompatibilities could be listed in a reasonably compact form (say, about six pages or so). A simple syntactic example is the acronym element, which is conforming in HTML 4, non-conforming in HTML5. A more complicated issue is the small element: in HTML 4, it means smaller font size; in HTML5, it has an obscure “semantic” definition as “small print” – so an HTML 4 document that validly uses small just for smaller font size is not HTML5 conformant.

There is no normative and rigorous list of the differences. Note that HTML5 is work in progress (and HTML 4 has some vagueness, even though it is formally “final”).

For most HTML 4 features that are declared as nonforming in HTML5, HTML5 requires continued support in browsers.

HTML5 does not cover everything that HTML 4 covers, even descriptively. In addition to declaring much of HTML 4 as obsolete, it leaves some HTML 4 features completely unspecified.

Upvotes: 3

Eduardo Casas
Eduardo Casas

Reputation: 578

Short answer: No, HTML4 is not compatible with HTML5 (starting with the doctype definition).

Long answer: http://www.w3.org/TR/html5-diff/

Upvotes: 0

Related Questions