My Net Source

<!DOCTYPE html>

According to the HTML standards, each webpage begins with a document type declaration or DTD for short. When a browser begins to load a page, it reads the DOCTYPE declaration and this declaration determines exactly how the browser will render the code within that page. Doctype is a declaration, not an HTML tag.

DOCTYPEs are required for legacy (older browsers) reasons. When omitted, browsers tend to use a different rendering mode (quirks mode) that is incompatible with some specifications. Including the DOCTYPE in a document ensures that the browser renders the page in standards mode.

Note : When the browser goes into quirks mode, it's trying to emulate an older version of the browser. This could cause the browser to ignore your page's style sheets and render the page unusable (Mozilla and Safari also have a third mode: almost standards mode, which mainly pertains to the vertical sizing of tables).

Unlike earlier versions of HTML, in HTML5 the doctype declaration is case-insensitive. In other words <!doctype html> works the same as <!DOCTYPE html>.

Doctype does 3 things :

  1. Identify the content of the document as conforming (theoretically) to a particular HTML
  2. Web browsers use it to determine which rendering mode they should use. Standards or Quirks.
  3. Markup validators look at the doctype to determine which rules should be used to check the document.

Specifying the doctype of your document allows you to use tools such as the Markup Validator to check the syntax of your HTML. Such tools won't work if they do not know what kind of document you are using. The doctype is a critical component of a quality HTML document.

DOCTYPE is a must use item. It means that you can write your web page in an HTML mode and the browser will render the webpage in whatever HTML version you tell it to. To the best of it's ability. Pertaining to a perfect website simply put the DOCTYPE declaration at the start of each of your webpages.

To indicate that your HTML content uses HTML5 - or HTML Living Standard - simply use:

<!DOCTYPE html>

Doing so will cause even browsers that don't presently support HTML5 to enter into standards mode, which means that they'll interpret the long-established parts of HTML in an HTML5-compliant way while ignoring the new features of HTML5 they don't support.

The WHATWG considers their work as living standard HTML for what constitutes the state of the art in major browser implementations by Apple (Safari), Google (Chrome), Mozilla (Firefox), Opera (Opera), and others. HTML5 is specified by the HTML Working Group of the W3C following the W3C process. As of 2013 both specifications are similar and mostly derived from each other, i.e., the work on HTML5 started with an older WHATWG draft, and later the WHATWG living standard was based on HTML5 drafts in 2011.

After the doctype declaration next comes the html-lang

Recources DOCTYPE syntax DOCTYPE syntax
Recommended list of Doctype declarations
Quirks Mode and Standards Mode
Activating Browser Modes with Doctype
Differences from HTML4
Don't forget to add a doctype
Gecko's "Almost Standards" Mode
Browser Peculiarities
Mozilla's DOCTYPE sniffing
Doctypes and their respective layout mode (February 2003)
Why Use DOCTYPE Declarations
Using a Custom DTD
Doctypes and markup styles