DOCTYPE

"A valid HTML document declares what version of HTML is used in the document."  So sayeth the W3C.  That is what the DOCTYPE statement does.

Truth

Without a DOCTYPE, a browser must guess at which version of HTML you are using. 

Without a DOCTYPE, a validation tool has no way of knowing which set of rules it should use to check your HTML.

Consequences

The allowable elements in HTML have changed over time.  In some cases the elements have not changed, but their defined meaning (or the browser-developer's interpretation of that meaning) has.  If the DOCTYPE is absent, incomplete, or incorrect, the browser may infer a version of HTML that is different from what you had in mind.  As a result, it may render your page in a manner other than what you intended.  Since different browsers may make different inferences about your intent, the absence of a DOCTYPE increases the liklihood that you will get different results from different browsers.

A validation tool needs to know what it is validating against.  If there's no DOCTYPE, it will probably guess, may guess wrong, and will spit out error messages that are of no value to you.  And (read the first line of this page again), the validator will scold you with at least one error message just for having left out the DOCTYPE.

Recommendations

Always specify a DOCTYPE.  Normally, you should use the HTML Strict doctype, which is:

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

The other possibilities are shown at http://www.w3.org/TR/html401/struct/global.html#version-info, but they are not recommended for the following reasons:

XHTML has its own DOCTYPEs, but see the XHTML page before considering its use.

Last revised 30 Jan 2006