The Doctype declaration is not an HTML Tag, It is used to tell the Browser about the version of HTML written on the web page. The Doctype tag is the first tag in HTML document you should write just before Html starting tag.
Table of Contents
Doctype Tag Example
<!DOCTYPE html>
<html>
<body>
<!--I am a DOCTYPE Tag with other HTML tags.-->
</body>
</html>
Case Sensitivity of Doctype Tag
The Doctype declaration is not case sensitive but It is always preferred to write it in upper case letters as shown above.
Doctype Declaration in HTML5
There are many versions of HTML but current version is HTML5. So now it's necessary to put HTML5 Doctype declaration whenever you write html code.
There is only one type of Doctype declaration in HTML5. This declaration will tell the browser that document is written in HTML5
Syntax of HTML5 Doctype declaration is as follow.
<!DOCTYPE html>
Doctype Declaration in previous versions of HTML
In earlier version of HTML, HTML 4.01, Doctype declaration was used for DTD. There are three different Doctype declarations in HTML 4.01.
DTD is a Document Type Definition. DTD defines the structure, elements, attributes and the rules for markup language in an XML document. HTML 4.01 was based on SGML.
All the rules and standards have only one purpose and that purpose is to display the content properly on the web page.
Note: HTML5 does not require a reference to DTD because it is not based on Standard Generalized Markup Language.
Types of DOCTYPE Declarations
Following are some types of Doctype declaration, HTML5 is the simplest one and you should only care about HTML5 one.
HTML 5 Doctype
<!DOCTYPE html>
HTML 4.01 Transitional Doctype
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
HTML 4.01 Frameset Doctype
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0 Strict Doctype
<!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
<!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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.1 Doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
HTML Doctype Tag Video
Watch our video on doctype tag and subscribe our Youtube Channel.