Leave a comment

Using DOCTYPE in html document

Ever wondered why !DOCTYPE html is written at the beginning of an HTML document. Well, it’s not an HTML tag. It’s an instruction to the web browser to tell about HTML version which is used to write that particular HTML document.

<!DOCTYPE html>
<html>
	<head>
		<title>This is test document</title>
	</head>
	<body>
		<p id="p1">First sentence</p>
		<p id="p2">Second sentence</p>
	</body>
</html>

 

Various DOCTYPE declarations

Let us see how DOCTYPE declaration is used for different versions of HTML

For HTML5

<!DOCTYPE html>

 

For HTML 4.01 Strict

For HTML4, DOCTYPE refers to DTD since HTML4 was based on SGML (Standard Generalized Markup Language). Therefore, browser use DTD to correctly render the HTML document.

<!DOCTYPE html public "=//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/Strict.dtd">

 

For HTML 4.01 Transitional

<!DOCTYPE html public "=//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">

 

For HTML 4.01 Frameset

<!DOCTYPE html public "=//W3C//DTD HTML 4.01 Frameset//EN" 
"http://www.w3.org/TR/html4/Frameset.dtd">

Leave a Reply

Your email address will not be published.


+ three = 8

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>