HTML Doctypes


A Document Type Declaration, or DOCTYPE, is an instruction to the Web browser about the version of markup language in which a page is written.

HTML5 Doctype

A DOCTYPE declaration appears at the top of a web page before all other elements. According to the HTML specification or standards, every HTML document requires a document type declaration to insure that your pages are displayed the way they are intended to be displayed. The doctype declaration is usually the very first thing defined in an HTML document; however the doctype declaration itself is not an HTML tag.

The DOCTYPE for HTML5 is very short, and case-insensitive.

<!DOCTYPE html>

Doctypes from earlier versions of HTML were longer because the HTML language was SGML-based and therefore required a reference to a DTD, but they are obsolete now. With HTML5 this is no longer the case and the doctype declaration is only needed to enable the standard mode for documents written using the HTML syntax.

You can use the following markup as a template to create a new HTML5 document that uses the latest HTML5 doctype declaration.

  • <!DOCTYPE html>
  • <html lang="en">
  • <head>
  •     <title><!-- Insert your title here --></title>
  • </head>
  • <body>
  •     <!-- Insert your content here -->
  • </body>
  • </html>

Note:The doctype declaration refers to a Document Type Definition (DTD). It is an instruction to the web browser about what version of the markup language the page is written in. The W3C provides DTDs for all HTML versions.


HTML 4.01 Different Doctypes

The following section contains the different doctypes from the previous version of HTML. Although using the HTML 4.01 doctypes are still a valid way to create DOCTYPE declaration, but they are no longer considered a best practice.

HTML 4.01 Strict

The HTML 4.01 Strict DTD includes all elements and attributes that have not been deprecatedor do not appear in frameset documents. For documents that use this DTD, use the following DOCTYPE declaration:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
http://www.w3.org/TR/html4/strict.dtd”&gt;

HTML 4.01 Transitional

The HTML 4.01 Transitional DTD includes everything in the strict DTD as well as deprecatedelements and attributes but excludes the frameset content. For documents that use this DTD, use the following DOCTYPE declaration:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”&gt;

HTML 4.01 Frameset

The HTML 4.01 Frameset DTD includes everything in the transitional DTD, as well as also allows the use of frameset content. For documents that use this DTD, use the following DOCTYPE declaration:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”&gt;

Warning:The <frameset> and <frame> elements has been removed from HTML5 and should no longer be used. Therefore, frameset DTD is no longer valid.


XHTML 1.1 Doctype

XHTML 1.1 is the most current finalized revision of XHTML 1.0 Strict, introducing support forXHTML Modularization, which means that you can add modules (for example, to provide Ruby support for Chinese, Japanese, and Korean characters).

For documents that use this DTD, use the following DOCTYPE declaration:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML Basic 1.1//EN” “http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd”&gt;

Tip:Must add a doctype to your HTML/XHTML document and use the W3C’s Validator to check the markup or syntax error before publishing online.

Source credits: http://www.tutorialrepublic.com/html-tutorial/html-doctypes.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s