What is DOCTYPE?

Light Bulb - TipWebsite Design Tips & Tricks

DOCTYPE (also known as DTD), is short for document type declaration. DocTypes are a key component of compliant web pages and should be the very first code of an html document, before the <html> tag.

A document type declaration, or DOCTYPE, is an instruction that associates a particular SGML or XML document (for example, a webpage) with a document type definition (DTD) (for example, the formal definition of a particular version of HTML).[1] In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax. (See Document Type Declaration Wikipedia Article.)

Definition and Usage

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

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.

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.

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

Read More at W3Schools.com

Why DOCTYPE? Per HTML and XHTML standards, a DOCTYPE (short for “document type declaration”) informs the validator which version of (X)HTML you’re using, and must appear at the very top of every web page. DOCTYPEs are a key component of compliant web pages: your markup and CSS won’t validate without them.

Read More at A List Apart

Lessons for beginners in plain english. Read about DOCTYPE at HTML5 Tutorial.

What is DOCTYPE?

A question asked to the Stack Overflow community. Stack Overflow is a question and answer site for professional and enthusiast programmers. Read the answers at Stack Overflow

According to HTML standards, each HTML document requires a document type declaration. The "DOCTYPE" begins the HTML document and tells a validator which version of HTML to use in checking the document's syntax.

If standard HTML does not meet your needs but you still wish to gain the benefits of HTML validation, see the section on using a custom DTD. Read More at Web Design Group

Valid DOCTYPE Recommended List from W3C

Recommended Doctype Declarations to use in your Web document.


Use the following markup as a template to create a new XHTML 1.0 document using a proper Doctype declaration. See the list below if you wish to use another DTD.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<p>… Your HTML content here …</p>  

HTML 4.01 Strict


HTML 4.01 Transitional

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

HTML 4.01 Frameset

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"

XHTML 1.0 Strict

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

XHTML 1.0 Transitional

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

XHTML 1.0 Frameset

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"