HTML5 doctype declaration – !DOCTYPE html

HTML5 doctype declaration – Document type declaration is the first line in any html document, it lets know browser what version of HTML we are using on that page. You can check any webpages doctype by viewing source code (Ctrl + U), check the first line that’s the doctype declaration. If you check this page’s html, you know that it’s HTML5 doctype declaration.

There are other types of document types, they are HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset, XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.

Example code of HTML5 doctype declaration

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HTML5 Document</title>
</head>

<body>
Content goes here...
</body>
</html>

Other common types of doctype declarations

  1. HTML 4.01 Strict
  2. HTML 4.01 Transitional
  3. HTML 4.01 Frameset
  4. XHTML 1.0 Strict
  5. XHTML 1.0 Transitional
  6. XHTML 1.0 Frameset
  7. XHTML 1.1

1) HTML 4.01 Strict

HTML 4.01 Strict DTD we can use all HTML elements and attributes, but does use presentational or deprecated elements (like font). Framesets are not allowed.

Example code of HTML 4.01 Strict

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HTML 4.01 Strict - doctype declaration</title>
</head>

<body>
Content goes here....
</body>
</html>

2) HTML 4.01 Transitional

Here are also we can use all HTML elements except presentational or deprecated elements (like font). Framesets are not allowed.

Example code of HTML 4.01 Transitional

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HTML 4.01 Transitional - doctype declaration</title>
</head>

<body>
Content goes here...
</body>
</html>

3) HTML 4.01 Frameset

Here also we can use all HTML tags, except deprecated tags. Here we can use frameset content also.

Example code of HTML 4.01 Frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HTML 4.01 Frameset - doctype declaration</title>
</head>

<body>
Content goes here...
</body>
</html>

4) XHTML 1.0 Strict

Here also we can use all HTML tags, except deprecated tags and framsets are not allowed. The markup must also be written as well-formed XML.

Example code of XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XHTML 1.0 Strict - doctype declaration</title>
</head>

<body>
Content goes here....
</body>
</html>

5) XHTML 1.0 Transitional

Here also we can use all HTML tags, except deprecated tags and framsets are not allowed. The markup must also be written as well-formed XML.

Example code of XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XHTML 1.0 Transitional - doctype declaration</title>
</head>

<body>
Content goes here...
</body>
</html>

6) XHTML 1.0 Frameset

Here also we can use all HTML tags, except deprecated tags and framsets are allowed. The markup must also be written as well-formed XML.

Example code of XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XHTML 1.0 Frameset - doctype declaration</title>
</head>

<body>
Content goes here...
</body>
</html>

7) XHTML 1.1

XHTML 1.1 DTD is equal to XHTML 1.0 Strict

Example code of XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XHTML 1.1 - doctype declaration</title>
</head>

<body>
Content goes here....
</body>
</html>

Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply:

x

Join My Facebook Group to Receive Coding Tutorial for Free

email-subsribe