Welcome Login

Html doctype declaration


DOCTYPE declaration:

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.

The <!DOCTYPE> declaration must be the very first thing in your html document, before the <html> tag.

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.

HTML5 is not based on SGML, and therefore does not require a reference to a DTD.

Always add the <!DOCTYPE> declaration to your html documents, so that the browser knows what type of document to expect.

 

Note: <!DOCTYPE> tag does not have an end tag.

Note2: <!DOCTYPE> declaration is not case sensitive.

 

 

 

Common doctype declarations:

HTML 5:

<!DOCTYPE html>

 

HTML 4.01 Strict:

This dtd contains all html elements and attributes, but does NOT include presentational or deprecated elements (like font). Framesets are not allowed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

 

HTML 4.01 Transitional:

This dtd contains all html elements and attributes, including presentational and deprecated elements (like font). Framesets are not allowed.

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

 

HTML 4.01 Frameset:

This dtd is equal to html 4.01 transitional, but allows the use of frameset content:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> 

 

 

Eg:

<!DOCTYPE html>

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

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

 

 

 

 

For more information, see here.


Created on: Thursday, August 22, 2013 by Andrew Sin