What is the DOCTYPE declaration in HTML?

The DOCTYPE declaration is used to inform the visitor’s web browser that the document being rendered is an HTML document. Every HTML document should be with a DOCTYPE declaration to be compliant with HTML standards. Without the DOCTYPE, we are forcing the browsers to render in Quirks Mode. DOCTYPE is partially used by the browsers to determine dialect and parsing. This is why HTML5 has reduced the DOCTYPE to simply.

What is doctype declaration
Doctype Declaration in HTML

A document type declaration, or DOCTYPE, is an instruction that associates a particular SGML or XML document (for example, a webpage) with a document type definition (DTD) (for example, the formal definition of a particular version of HTML1.0 – HTML 4.0). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.

  1. The DOCTYPE Declaration is not mandatory in HTML5
  2. The DOCTYPE is not an HTML element or tag.
  3. DOCTYPE gives an instruction to the web browser about the version of HTML we are using on our web page.
  4. If we declare the DOCTYPE then it should be the first thing in our HTML document and we have to declare it before the tag.
  5. The declaration is NOT case sensitive.

HTLM Doctype Declaration for Different Version’s:

HTML 5

<!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">

There were some other doctype declarations in previous HTML versions, for more details visit W3C

  • MathML Doctype Declarations
  • Compound documents doctype declarations
  • Optional doctype declarations
  • Historical doctype declarations

Leave a Comment

Scroll to Top