The DTD(<DOCTYPE>) document Type Declaration tells the browser which version of (X)HTML you’re using, so it will know how to display the page. The doctype declaration refers to a Document Type Definition (DTD). The document type declaration must be appaer at the beginning of your code that includes a reference to the DTD for the markup language your Web page uses.
The DOCTYPE declaration is also necessary if you want to use a validation tool to ensure that your html is valid.
A DOCTYPE declaration consists of two parts.
- A definition of the HTML version that a web page use.
- A path called URI (uniform resource identifier), to the Document Type Definition(DTD) that define the (X)HTML version.
There are three types of DTDs, which can be specified using the DOCTYPE tags in either XHTML or HTML.
- Strict: This DTD contains all HTML elements and attributes. Use strict DTD when you want a clean markup, free of presentational clutter. In DTD strict all styles will be handled by CSS. It does not support presentational or formatting tags (like font, center, u). Also Framesets are not allowed.
- Transitional: This DTD contains all HTML elements ans attributes, including presentational and formatting tags. Allow you to use a mixture of CSS and legacy HTML formatting to design a page. Framesets are also not allowed.
- Frameset: This DTD contains everything in the transitional DTD plus elements and attributes to creating frames.
The general syntax for a Document Type Declaration is:
<!– internal declarations –> ]>
Example: Let’s say for XHTML 1.0
XHTML Strict DTD is the most strict DTD available: no deprecated tags are supported and the code must be written correctly.
XHTML Transitional DTD is like the XHTML Strict DTD, but deprecated tags are allowed. This is the most popular current DTD.
XHTML Frameset DTD is the only XHTML DTD that supports Frameset. The DTD is below.
you can find HTML’s all versions dtd here: