Bharat Singh
Bharat Singh

Reputation: 1

Difference between html4 and html5 tag doctype tag?

Difference between html4 and html5 tag doctype tag?

Upvotes: 0

Views: 6896

Answers (3)

Quentin
Quentin

Reputation: 943562

The HTML 4 Doctypes describe the root element, and provides two ways (a URL and a code for finding it if you have a local copy) for finding the DTD (so you can expand entities, perform validation and know which tags are optional and which are required for any given element). As a side effect, they trigger standards mode in browsers.

The HTML 5 Doctype is a magic string that triggers standards mode in browsers. It doesn't do anything else because the working group have abandoned the idea of HTML being an application of a generic markup language and require specialized parsers for it.

Upvotes: 3

naikus
naikus

Reputation: 24472

The difference?

Is that the html5 doctype declaration insanely simple, no more references to dtds, like strict, transitional, etc:

<!DOCTYPE html>

Why this was used? The spec says:

DOCTYPEs from earlier versions of HTML were longer because the HTML language was SGML-based and therefore required a reference to a DTD. With HTML5 this is no longer the case and the DOCTYPE is only needed to enable standards mode for documents written using the HTML syntax.

Upvotes: 1

Garis M Suero
Garis M Suero

Reputation: 8169

As said in HTML5 (W3)

2.2. The DOCTYPE

The HTML syntax of HTML5 requires a DOCTYPE to be specified to ensure that the browser renders the page in standards mode. The DOCTYPE has no other purpose and is therefore optional for XML. Documents with an XML media type are always handled in standards mode. [DOCTYPE]

The DOCTYPE declaration is and is case-insensitive in the HTML syntax. DOCTYPEs from earlier versions of HTML were longer because the HTML language was SGML-based and therefore required a reference to a DTD. With HTML5 this is no longer the case and the DOCTYPE is only needed to enable standards mode for documents written using the HTML syntax. Browsers already do this for .

References:

Upvotes: 0

Related Questions