DOCTYPE
is short for "document type" and is used in web design to indicate the version of XHTML or HTML being used.
HTML5
does not rely on SGML
, so it does not require a reference to a DTD
.
The <!DOCTYPE html>
declaration must be the first line of an HTML document and should be placed before the <html>
tag.
In HTML 4.01, the <!DOCTYPE>
declaration references a DTD
because HTML 4.01 is based on SGML
. The DTD
specifies the rules of the markup language so that browsers can correctly render the content.
The DTD
in the above example is called a Document Type Definition, which contains the rules for the document. The browser interprets the markup of your page based on the defined DTD
and displays it accordingly.
To create a standards-compliant webpage, the DOCTYPE
declaration is an essential component. Without a correct DOCTYPE
for your XHTML, neither the markup nor the CSS will be effective.
DTD
and allows the continued use of HTML 4.01 markup (but in the syntax of XHTML). The complete code is as follows:DTD
and does not allow the use of any presentational markup or attributes, such as <br>
. The complete code is as follows:DTD
. The complete code is as follows: