Monday , September 21 2020

DOCTYPE HTML Tag Declaration

Basically, DOCTYPE HTML is not an HTML element; it is an instruction to inform the browser, what type of the HTML version is used in the HTML file.

The <!DOCTYPE html> document type declaration is very important and must be inserted before the <HTML> tag.

The HTML !DOCTYPE tag is the very first thing that every web document should have.

The Document Type Declaration (DTD) is unique for each version of HTML and must be written exactly as it is, to be of some use. For this reason, it’s better if you just copy and paste the code for the declaration you’re about to use.

Below is a list of DTDs for all the versions of HTML (XHTML included), and others like SVG and MathML. But remember that, as of today, there’s no need to use any other declaration than the one for HTML5, as this is, by far, the preferred version (unless you’re working on a very particular project).

In HTML5, the !DOCTYPE declaration remains only for legacy reasons pertaining to processing modes in browsers.

Read: Complete HTML Tags List

Example of <!DOCTYPE html> Tag

<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p> Body content of the document </p>
</body>
</html>

Different <!DOCTYPE HTML> Declaration:

HTML5

The HTML5 is using is very simple document type.

<!DOCTYPE html>

HTML 4.01 Strict

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

HTML 4.01 Transitional

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

HTML 4.01 Frameset

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

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Browser Support <!DOCTYPE HTML>:

  • Inter Explorer (all)
  • Google Chrome (all)
  • Firefox (all)
  • Safari (all)
  • Opera (all)