HTML Doctype

What is the Doctype in HTML and XHTML documents. We see different types of Doctype available.

Within the framework of our and in general lines, we can say that the DOCTYPE is a declaration of the standard used when building an HTML or XHTML document.

However, to be a bit more strict, we must clarify that the Doctype is typical of XML and SGML documents, and therefore the HTML or XHTML languages ​​are simple heirs of something that was already being used.

The standard used in a document is defined using a DTD, which stands for Definition Type Document, and is a declaration in one metalanguage to define another language. In other words, the DTD marks the rules for the definition of languages ​​such as HTML and in the Doctype we are simply indicating which DTD must be used to interpret the HTML document that we are coding.

Thus, in summary, we could say that HTML or XHTML documents are written in a language and with the Doctype we specify this language and its version. Browsers will read this doctype declaration and interpret the page according to the rules defined in that language.

Note: It is important for browsers to know the doctype of the web page, because that way they can display the web page with the exact version of the HTML or XHTML language with which it was built. If they don’t have a doctype declaration, they will interpret the page in what is called “quirks mode”, a mode that seeks to maximize the page’s compatibility with older versions of the HTML language. For more information on this approach to explaining the doctype, we recommend reading the article on the .

See also  HTML Syntax

So the use of the tag is necessary if we want to comply with an HTML or XHTML standard, to specify which version or language we use and for the browser to render the page according to said standard.

The DOCTYPE has a form as follows:

PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

The doctype must be included in the first line of the page’s HTML code.

To somehow explain this tag, which sounds a bit Chinese, it says that it is a DOCTYPE of an HTML document and gives us two additional pieces of information. With the text “-//W3C//DTD XHTML 1.0 Transitional//EN” we indicate that this document has to be validated against the XHTML 1.0 specification and that the document type is Transitional. On the other hand, http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd is the URL of the DTD that is used to validate the HTML code of the page.

The document type, which we had marked as Transitional in the doctype expressed above, means the document uses a wider range of HTML tags and attributes, including some that may have been deprecated. There are two other types of documents. On the one hand we have strict, which indicates that the code is strict HTML or XHTML, without including obsolete attributes and tags. The other type of document that is missing is the frameset, which is used when we are making a frameset declaration.

So, depending on our page and the code we use, we will have to declare one or the other doctype. There are various Doctypes that cover a wide range of possibilities, configuring different versions of HTML or XHTML and different types of documents, strict, transitional or frameset. This .com web development article is now completed with a list of some of these most used doctypes today:

See also  Inheritance in PHP

Doctype XHTML 1.0 strict

PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

Doctype XHTML 1.0 transitional

PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

Doctype XHTML 1.0 frameset

PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>

Doctype HTML 4.01 strict


Doctype HTML 4.01 transitional


Doctype HTML 4.01 frameset


Loading Facebook Comments ...
Loading Disqus Comments ...