A Document Type Definition (DTD) is a set of rules that define the document structure in a particular version of XML or (X)HTML. A browser will parse the web page looking for the Document Type (DOCTYPE) Declaration in your CSS code and will use these rules to validate the page.
An example of Document Type (DOCTYPE) Declaration is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
The DOCTYPE declaration is included at the start of the (X)HTML document. It is required in order for the page to validate as the browser needs to know which DTD to use in order to process the page correctly.
In the previous example the DTD XHTML 1.0 Transitional is used.
It’s important to validate all the pages and often, especially while coding, in order to find out bugs in your code.
However, most older browsers did not fully implement the CSS specifications or were developed before the finale release of the specifications. Therefore, many older web pages were built referring to these incomplete or incorrect browsers’ implementations.
To ensure backward compatibility browsers includes two rendering modes: Standards and Quirks mode.
In Standards mode the browsers render a page according to the specifications and in Quirks mode they emulate the behavior of older browsers.
Some browsers (Mozilla and Safari for example) also include an “Almost Standards” mode which attempts to compromise between the two previous modes, trying to emulate some older quirks while at same time mostly conforming to the specifications.
Basically an XHTML document containing a fully formed DOCTYPE is rendered in Standards mode. An HTML 4.01 document with Strict DTD (with or without URI) is rendered also in Standards mode, with Transitional DTD + URI is rendered in Standards mode, while with transitional DTD without URI is rendered in Quirks mode.
So if you wrote good CSS but yor DOCTYPE is uncorrect, your page may not be rendered in the desired way or not be rendered at all. Therefore it’s very important to include a fully formed DOCTYPE declaration on every page of the website!
N.B. IE6 requires this declaration to be the first line of the (X)HTML code. If not it switches to Quirks mode.