Bob Bob - 8 months ago 54
HTML Question

What is DOCTYPE?

  • What is DOCTYPE and why do I want to use it?

  • What are the different DOCTYPEs I can use?

  • What is the difference between standards and quirks mode, and what are some quirks I may run into with differently set DOCTYPEs?

Lastly, what is the proper DOCTYPE that I should be using?


Basically, the DOCTYPE describes the HTML that will be used in your page.

Browsers also use the DOCTYPE to determine how to render a page. Not including a DOCTYPE or including an incorrect DOCTYPE can trigger quirks mode. The kicker here is that quirks mode in Internet Explorer is quite different from quirks mode in Firefox (and other browsers), meaning that you'll have a much harder job trying to ensure your page works consistently in all browsers if pages are rendered in quirks mode than you will if they are rendered in standards mode.

Wikipedia has a more indepth summary of the differences in rendering when using various DOCTYPEs. XHTML is enabled by certain doctypes, and there is quite a bit of debate about the use of XHTML which is covered well in XHTML — myths and reality.

There are subtle differences between different "standards complaint" rendering doctypes, such as the HTML5 doctype (<!DOCTYPE html>, prior to HTML5 only known as the "skinny doctype" which not trigger standardised rendering in older browsers) and other DOCTYPEs such as this one for HTML 4.01 transitional:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">