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.
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:
<!DOCTYPE Root element Publicity "Registration//Organization//Type Name//Language" "URL">
<!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 |
|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:|
|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:|
|HTML 4.01 Frameset||In the HTML 4.01 Frameset Document Type Definition (DTD), users can use Frames, written as:|
|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:|
|XHTML 1.0 Transitional||In the XHTML 1.0 Transitional Document Type Definition (DTD), elements that become obsolete are allowed, written as:|
|XHTML 1.0 Frameset||In the XHTML 1.0 Frameset Document Type Definition (DTD), users can use framesets, written as:|
|XHTML 1.1||The XHTML 1.1 Document Type Definition (DTD) permits the addition of modules written as:|
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).