What is the DOCTYPE declaration in HTML?

Why do we use DOCTYPE & a details guideline on doctype declaration

Doctype Declaration

The DOCTYPE declaration is used to inform the visitor’s web browser that the document being rendered is an HTML document. Every HTML document should be with a DOCTYPE declaration to be compliant with HTML standards. Without the DOCTYPE, we are forcing the browsers to render in Quirks Mode. DOCTYPE is partially used by the browsers to determine dialect and parsing. This is why HTML5 has reduced the DOCTYPE to simply.

What does a web developer do?

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 HTML1.0 – HTML 4.0). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.

  1. The DOCTYPE Declaration is not mandatory in HTML5
  2. The DOCTYPE is not an HTML element or tag.
  3. DOCTYPE gives an instruction to the web browser about the version of HTML we are using on our web page.
  4. If we declare the DOCTYPE then it should be the first thing in our HTML document and we have to declare it before the tag.
  5. The declaration is NOT case-sensitive.

HTLM Doctype declaration for different version’s

HTML 5

<!DOCTYPE html>

HTML 4.01 Strict

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

HTML 4.01 Transitional

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

HTML 4.01 Frameset

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

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

There were some other doctype declarations in previous HTML versions, for more details visit W3C

  • MathML Doctype Declarations
  • Compound documents doctype declarations
  • Optional doctype declarations
  • Historical doctype declarations

Details documentation from W3C

Summary

Doctype is very important for an HTML document and it is best practice to always use doctype at the beginning of your HTML document.

November 6, 2022
Uncategorized

Elementor: The Page Builder for WordPress That Makes Design Easy

/*! elementor - v3.8.0 - 30-10-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
November 6, 2022
Uncategorized

How to Become a Digital Entrepreneur

/*! elementor - v3.8.0 - 30-10-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
November 6, 2022
Uncategorized

Why Should You Take Digital Marketing Business Seriously?

/*! elementor - v3.8.0 - 30-10-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
November 6, 2022
Uncategorized

What Is Digital Entrepreneurship?

/*! elementor - v3.8.0 - 30-10-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
November 6, 2022
Uncategorized

What do you need to be a Digital Entrepreneur?

/*! elementor - v3.8.0 - 30-10-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
November 6, 2022
Web Design

What is the DOCTYPE declaration in HTML?

/*! elementor - v3.8.0 - 30-10-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
November 6, 2022
Web Development

Web Developer in Bangladesh

/*! elementor - v3.8.0 - 30-10-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
November 25, 2022
Web Design, Web Development, WordPress

Hosting

/*! elementor - v3.8.1 - 13-11-2022 */ .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading […]
Scroll to Top