HTML5 Doctype

Doctype informs the web browser to render the page in standard mode. This is the first line in every html document. The Doctype tag varies based on version. For HTML5 the doctype declaration is -

<!doctype html>

The above tag is required in every HTML5 document according to W3C. This should always be the first line of the HTML document. It displays nothing to the web page and it does not have any closing tag.

Example

<!doctype html>
<html>
<head>
<title>Html5 Document</title>
</head>
<body>
<p>Content goes here.</p>
</body>
</html>

The doctype declaration of HTML versions prior to HTML5 need declaration of DTD and very long. It was very difficult to remember them. So HTML5 introduced a very short doctype declaration.

The doctype declaration of HTML versions prior to HTML5

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.1 Doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> 






Read more articles


General Knowledge



Learn Popular Language