Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 is not based on SGML, and therefore does not require a reference to a DTD

Tags:

html

dtd

From: http://www.w3schools.com/tags/tag_doctype.asp

The < !DOCTYPE > declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.

In HTML 4.01, the < !DOCTYPE > declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.

HTML5 is not based on SGML, and therefore does not require a reference to a DTD.

Tip: Always add the < !DOCTYPE > declaration to your HTML documents, so that the browser knows what type of document to expect.

Does the bold statement mean that when we are using HTML 5 we don't need to specify < !DOCTYPE html >?
What does that statement exactly mean?

I am currently using < !DOCTYPE html > in my html file with the browser Firefox 4. I removed that declaration but did not see any difference in the rendered output. Does it mean that the problem may occur in old browsers and not in new ones?

like image 693
Aquarius_Girl Avatar asked Apr 24 '13 06:04

Aquarius_Girl


People also ask

Is HTML5 based on SGML?

The HTML5 syntax is no longer based on SGML despite the similarity of its markup.

Does HTML5 use DTD?

HTML5 doctype does not reference to a DTD. This is because, html5 is a SGML based, unlike HTML4. 01 or XHTML1.

Why is HTML5 not based on SGML?

Of course HTML5 is for a large part based on HTML4 (based on SGML) and XHTML (based on HTML4 and XML). Because HTML5 explicitly allows proprietary tags without declaration there is no DTD and HTML5 is not based on SGML but is it´s own standard.

Does HTML have a DTD?

In HTML 4.01, the DOCTYPE declaration refers to a document type definition (DTD). A DTD defines the structure and the legal elements of an XML document. Because HTML 4.01 was based on the Standard Generalised Markup Language (SGML), referring to a DTD in the DOCTYPE declaration was necessary.


2 Answers

The terminology is confusing, but a DTD (document type definition) is only one part of a document type declaration (usually shortened to "doctype"). You should always include a doctype declaration (<!DOCTYPE html> if you use HTML5), but a document type definition identifier is no longer necessary.

To provide a concrete example, this is what a HTML4.01 document type declaration ("doctype") might have looked like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

The document type definition ("DTD") identifier in the above declaration is this part:

"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"

That's the part you can leave off for HTML5. "PUBLIC" specifies the DTD's availability, so that should also not be included if there is no DTD.

like image 97
Matt Kantor Avatar answered Oct 14 '22 08:10

Matt Kantor


Does the bold statement mean that when we are using HTML 5 we don't need to specify ?

It means that you can't specify.

The HTML 5 Doctype has no public or system identifier in it.

I am currently using <!DOCTYPE html> in my html file

That is required. Keep doing that.

with the browser Firefox 4.

The current stable version of Firefox is version 20. You should probably upgrade.

I removed that declaration but did not see any difference in the rendered output. Does it mean that the problem may occur in old browsers and not in new ones?

No, it just means that you don't have any code that is impacted by being in Quirks mode (or that you do but didn't spot the changes).

like image 29
Quentin Avatar answered Oct 14 '22 10:10

Quentin