What Is Doctype In HTML5 Which Doctype Is Correct For HTML5

What Is Doctype In HTML5? Which Doctype Is Correct For HTML5

What Is Doctype In HTML5

The HTML document type declaration, also known as DOCTYPE, is the first line of code required in every HTML or XHTML document. The declaration is an instruction to the web browser about what version of HTML the page is written in. This ensures that the web page is parsed the same way by different web browsers.

Declaration of a 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 ensure that the pages are displayed in the way they are intended to be displayed.

<!DOCTYPE html>

Doctype syntax for strict HTML 4.01:

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

Doctype syntax for transitional HTML 4.01:

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

Doctype syntax for frameset HTML 4.01:

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

 

Also Read 

 

Why we use doctype in HTML?

The Doctype does two things.

  1. It identifies which dialect of HTML you’re using.
  2. It controls whether the browsers use “standards” or “quirks” mode to render the document.

If there is no doctype, or there’s an unrecognized one, then it uses “quirks” mode and interprets the document as best it can. If there IS a doctype, and it recognizes it, then it follows the standards. The results of the rendering can vary depending on how it interprets the document.

 

DOCTYPE Results

First, let’s take a look at a table containing the raw data that was produced.

From Name DOCTYPE
Amazon Echo HTML 5
Amazon Web Services XHTML 1.0 Transitional
Boost Mobile HTML 4.0 Transitional
Credit Karma HTML 5
Dropbox HTML 4.0 Transitional
Facebook HTML 4.01 Transitional
Google Analytics XHTML 1.0 Strict
Google Cloud Platform HTML 5
Google Local Guides HTML 5
Heroku XHTML 1.0 Transitional
Instagram HTML 4.0 Transitional
Jimmy John’s XHTML 1.0 Strict
Litmus HTML 5
Microsoft Azure XHTML 1.0 Strict
Netflix XHTML 1.0 Transitional
Newegg.com HTML 4.01 Transitional
PayPal XHTML 1.0 Transitional
Pizza Hut XHTML 1.0 Transitional
Target HTML 5
The Washington Post XHTML 1.0 Transitional
Twilio SendGrid HTML 4.01 Transitional
Twitter XHTML 1.0 Transitional
Vanguard HTML 5
Wayfair XHTML 1.0 Transitional
Yahoo Small Business HTML 5