Why do I need a doctype and what does it do?

Technology CommunityCategory: HTML5Why do I need a doctype and what does it do?
VietMX Staff asked 3 years ago

The Doctype does two things.

  • It identifies which dialect of HTML you’re using.
  • It controls whether the browsers uses “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.