The document type declaration (DTD) is not a HTML tag; it is an URI that helps a browser determine what kind of the document it is dealing with.

DTD declares what type of the HTML document is to be rendered and its entity set. The main differences in DTDs are variations in elements they support.

It has to be added to the HTML at the beginning of the document and before the <html> tag.

In HTML 4.01 there are three DTDs that developers must choose from in order to define the document properly:

HTML 4.01 Strict DTD (default DTD)

Includes all elements and attributes that have not been deprecated or don't appear in the frameset type of documents.

HTML 4.01 Transitional DTD

Includes everything from the strict DTD including the deprecated elements.

TML 4.01 Frameset DTD

Includes everything from the transitional DTD and the frames.

It's worth noticing that in HTML 4.01 the transitional DTD's URI is called loose.dtd (look below) while in XHTML 1.0 it is replaced with transitional.dtd.

Syntax:

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

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

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

 

›› go to examples ››