Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"<!DOCTYPE html>" What does it mean?

Tags:

html

doctype

I use a fantastic javascript organization tree generator named "ECOTree" but the drawing does not work when I put <!DOCTYPE html>. Labels in the boxes are not put in the boxes correctly.

You can see the error at sample1.htm on the site below. Could anybody suggest me how to fix. http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=16192

(In order to follow my project rule, I have to define <!DOCTYPE html>)

like image 660
zono Avatar asked Feb 19 '12 05:02

zono


2 Answers

<!DOCTYPE html> is the explicit Document Type Declaration.

From the linked page:

The DOCTYPE Declaration (DTD or Document Type Declaration) does a couple of things:

  1. When performing HTML validation testing on a web page it tells the HTML (HyperText Markup Language) validator which version of (X)HTML standard the web page coding is supposed to comply with. When you validate your web page the HTML validator checks the coding against the applicable standard then reports which portions of the coding do not pass HTML validation (are not compliant).
  2. It tells the browser how to render the page in standards compliant mode.

#2 is a very important reason for using it.

<!DOCTYPE html>, specifically, is the correct declaration for HTML5, and should be used pretty much from here to the near future. You can still use legacy strings or obsolete permitted strings, but the previously written format is all that is required in HTML5. On a further note, this DTD will cause all modern browsers dead link to switch to their standards (compliance) mode, even if they don't support HTML5.

Here's some more info:

Activating Browser Modes with Doctype & Choosing a Doctype (same page)
World Wide Web Consortium (they make web standards)

like image 109
rockerest Avatar answered Sep 19 '22 15:09

rockerest


<!DOCTYPE html> is not a "Document Type Declaration".

A "Document Type Declaration" is an SGML concept for signalling the mark-up syntax and vocabulary for the mark-up that follows. <!DOCTYPE html> does not conform to the requirements of that. This is unlike <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> which is a SGML conforming Document Type Declaration.

<!DOCTYPE html> does not indicate an HTML5 document.

Although HTML5 conforming documents in the text/html serialization are required to have <!DOCTYPE html> at their start, it does not follow that the converse is true. I.e. a document can have <!DOCTYPE html> at its start and not be an HTML5 document. For example, it is intended that all future versions of HTML will use the same character sequence at their start. So it might indicate an HTML5 document, or an HTML6, HTML7 etc. document, an HTML5+RDFa-lite document, or a document from an entirely competing standard.

The HTML5 spec describes <!DOCTYPE html> as "a required preamble", and that's much closer to the mark.

It's just the shortest character sequence that will request to legacy as well as future browsers that the browser should handle the HTML of the document using its most modern HTML processing mode. It was chosen as the conforming preamble for HTML5 for solely that reason.

If it can be said to have any meaning at all, it is that it indicates that the document was created or last refactored around about 2007 or later. Again, the converse does not necessarily apply. A document not containing <!DOCTYPE html> does not imply that the document was created before any particular date.

like image 37
Alohci Avatar answered Sep 19 '22 15:09

Alohci