!DOCTYPE html5

What is Doctype in HTML?

HTML5 Doctype Declaration Example – The <!DOCTYPE> declaration must be the very first thing in your HTML document, before the <html> tag.The <!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.In HTML 4.01, the <!DOCTYPE> declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly. HTML Doctype: – A Document Type Declaration, or?DOCTYPE?for short, is an instruction to the web browser about the version of markup language in which a web page is written. A HTML DOCTYPE?declaration appears at the top of a web page before all other elements.

Declaring a DOCTYPE

All HTML need to have a DOCTYPE declared. The DOCTYPE is not actually an element or HTML tag. It lets the browser know how the document should be interpreted, by indicating what version or standard of HTML (or other markup language) is being used.

How to Declare Doctype?

The DOCTYPE declaration comes before any other element in a HTML document. However, it is not a tag which implies that it will not be used to pass instructions user-defined instructions to a web browser. Instead, it prompts the browser about the version of HTML in which a web document is written to ensure that it is presented correctly. The DOCTYPE for HTML5 is short:

All HTML need to have a DOCTYPE declared. The DOCTYPE is not actually an element or HTML tag. It lets the browser know how the document should be interpreted, by indicating what version or standard of HTML (or other markup language) is being used.

HTML5 Doctype Declaration Example

<!DOCTYPE html>

This needs to be the first thing in your document, before the?<html>?or?<head>?elements. Also, there is no closing tag.

<!DOCTYPE html> 
<html> 
<head> 
* 
* 
* 
</head> 
<body>
 *
 * 
 * 
</body> 
</html>

Note that the doctypes for previous versions of HTML were characteristically longer because their SGML-based language required a reference to DTD. The release of HTML 5 made them obsolete ? in the latest release, the DOCTYPE declaration is only needed to ensure that a developer?s code is consistent with the conventions of writing standard HTML syntax.

As stated earlier, each version of the HTML language has its own DOCTYPE declaration. Although they are no longer in use, below are various DOCTYPES that were used with HTML 4.01.

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

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

What is Elements in HTML5?

Example of Doctype?

<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>

<body>
The content of the document......
</body>

</html>

With the exception of the lack of a URI or the FPI string (the FPI string is treated case sensitively by validators), this format (a case-insensitive match of the string !DOCTYPE HTML) is the same as found in the syntax of the SGML based HTML 4.01 DOCTYPE. Both in HTML4 and in HTML5, the formal syntax is defined in upper case letters, even if both lower case and mixes of lower case upper case are also treated as valid.

In XHTML5 the DOCTYPE must be a case-sensitive match of the string “<!DOCTYPE html>”. This is because in XHTML syntax all HTML element names are required to be in lower case, including the root element referenced inside the HTML5 DOCTYPE.

The DOCTYPE is optional in XHTML5 and may simply be omitted. However, if the markup is to be processed as both XML and HTML, a DOCTYPE should be used.