The DTD affects the way a webpage displays in different browsers. This is particularly noticeable when setting type sizes and also affects the padding and spacing around elements.
The document type definition (DTD) is the validation standard used by a browsing device when it displays a webpage. The definition specifies the code base used (language) by the webpage (and consequently the elements that are permitted/valid).
Using a linguistic analogy; the DTD is comparable to a dialect. Some words (elements) may be shared amongst dialects, but others will be unique to a single dialect. The ‘big ideas’ are readily understood, but the nuance may be lost. In the case of displaying a webpage, this nuance may relate to the size of the type, space around form elements, etc.
Due to the constant evolution of standards, DTDs allow for a degree of flexibility. This flexibility is referred to as ‘interpretation’ and can be set to one of three values;
The document type declaration is often referred to as the ‘doctype’.
The DTD is specified in a document type declaration, the formal ‘presentation’ of the chosen DTD. The declaration is made before the content of the webpage.
Sample document type declaration, specifying a (strict) DTD:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-HTML40/strict.dtd" />
Thanks to Greg Feldman for ‘ironing out the kinks’ in our description
deprecated, frames/frameset, quirks mode, elements,tags, validation
content-type is communicated to the browser by a content-type header, i.e. the content-type is set by the server. Although a doctype may specify XHTML, the content-type must also be set to application/xhtml+xml, to correctly serve the document. Unfortunately Internet Explorer 6 does not correctly interpret the xhtml+xml content-type header…