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

zono picture zono · Feb 19, 2012 · Viewed 96.6k times · Source

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>)

Answer

rockerest picture rockerest · Feb 19, 2012

<!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)