Have you ever heard about HTML Doctype Declaration; It plays an essential role in an HTML document. This tutorial presents descriptive info about HTML Doctype.



What is HTML DOCTYPE?

HTML Doctype Declaration refers to a Document Type Definition (DTD). A DTD refers to an XML document format representing allowed elements in a web page. Every HTML document requires a document type declaration. It is a directive that tells the web browser about the HTML version and standard in which the current page is written; this helps different web browsers parse the web page correctly. Technically the Doctype declaration does not belong to the category of tag or element in HTML. It is just a directive to the web browser about the type of HTML document. It is a null element with no closing tag.

Doctype Declaration

These are some of the points which are essential to know for the Doctype Declaration:

  • The doctype declaration should be on the first line at the top of all other content on the web page.
  • The Doctype declaration was long for earlier versions of HTML because the HTML language was SGML-based and therefore required reference to DTDs, but they are now obsolete.
  • The HTML5 doctype declaration is concise, easy to use, reliable, and case-insensitive.
  • In HTML5, only the doctype declaration is required to enable standards mode for web pages.

Doctype declaration differs in different HTML versions. Below is an example template of HTML 5 doctype declaration:

Syntax:

<!DOCTYPE Root element Publicity "Registration//Organization//Type Name//Language" "URL">

Example:

<!DOCTYPE html>
<html lang="en-US">

    <head>
        <title>Example of HTML5 Doctype declaration</title>
    </head>

    <body>The body of the web page.</body>

</html>

XHTML Doctype Declarations List

List of the commonly used <!DOCTYPE> Declaration for a different version of HTML and XHTML:

HTML5 This version of HTML includes the easiest way of declaring the <!DOCTYPE> declaration written as:<!DOCTYPE html>
HTML 4.01 Strict In HTML 4.01 Strict Document Type Definition (DTD), Users can include all the elements and attributes that do not arise in the frameset documents and have not become obsolete. It is written as:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML 4.01 Transitional The HTML 4.01 Transitional Document Type Definition (DTD) authorizes some of the older public and attributes that have become obsolete. It is written like this:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
HTML 4.01 Frameset In the HTML 4.01 Frameset Document Type Definition (DTD), users can use Frames, written as:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0 Strict In the XHTML 1.0 Strict Document Type Definition (DTD), the browser does not support deprecated tags, and users must write the code according to the XML Specification, written as:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 Transitional In the XHTML 1.0 Transitional Document Type Definition (DTD), elements that become obsolete are allowed, written as:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML 1.0 Frameset In the XHTML 1.0 Frameset Document Type Definition (DTD), users can use framesets, written as:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.1 The XHTML 1.1 Document Type Definition (DTD) permits the addition of modules written as:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

HTML <!DOCTYPE> Parameters

In earlier versions of HTML, some parameters are attached to the doctype:

  • Root element: It represents the root element of the document. <HTML> for HTML or XHTML.
  • Publicity: The Publicity parameter can be either PUBLIC or SYSTEM. For HTML or XHTML, the DOCTYPE value is PUBLIC.
  • Registration: It can hold two values, namely plus (+), which lists the International Organization for Standardization (ISO) developer, and minus (-), not registering the International Organization for Standardization (ISO) developer.
  • Organization: It is the name of the DTD developer. W3C for HTML or XHTML.
  • Type: It declares the document type. DTD for HTML or XHTML.
  • Name: It defines the unique identifier illustrating DTD.
  • Language: The HTML document with the language type, two letters in uppercase. For HTML or XHTML, English (EN) is the language.
  • URL: It defines the Document Type Description URL (for example, https://www.w3.org/TR/html4/strict.dtd).


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram