<!DOCTYPE ...>
Usage Recommendation |
Use this tag if you want to use an SGML/HTML validator. Otherwise, this tag is of little use. |
The <!DOCTYPE ...>
declaration (technically it's not a "tag") should be the very first thing in your document... if you choose to use it at all. <!DOCTYPE ...>
tells the browser what version of HTML you are writing in. More specifically, <!DOCTYPE ...>
declares that this document conforms to a specific version of HTML, and specifies what version that is.
The necessity of <!DOCTYPE ...>
is a subject of much debate. The standards published by W3C require the use of <!DOCTYPE ...>
. However, much of the HTML being written does not conform strictly the W3C specifications, and so using <!DOCTYPE ...>
(which is, after all, a claim that you conform to the standards) would seem unnecessary.
However, <!DOCTYPE ...>
has its place on a page, even if you decide to use a little non-standard markup. <!DOCTYPE ...>
's most useful purpose
is when used in conjunction with one of the various HTML analyzers. The analyzers look to the <!DOCTYPE ...>
to determine what type of HTML you are trying to write. Our recommendation is that you use the appropriate <!DOCTYPE ...>
. It won't hurt and allows you to make use of the HTML checkers available.
This is the <!DOCTYPE ...>
declaration for HTML version 3.2:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
For HTML 4.0, the situation is a little more complicated. There are three standard doctypes. The DTD for documents that strictly conform (don't use any deprecated markup) and that aren't frameset documents, use this <!DOCTYPE ...>
:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"https://www.w3.org/TR/REC-html40/strict.dtd">
For a not quite so strict conformance (uses some of the deprecated markup such as <CENTER ...>
), use this <!DOCTYPE ...>
:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"https://www.w3.org/TR/REC-html40/loose.dtd">
Finally, for documents which are frameset documents (the "top" document in a framed page), use this <!DOCTYPE ...>
:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
"https://www.w3.org/TR/REC-html40/frameset.dtd">