Chapter 2: Doctypes
Doctypes (short for 'document type') help browsers understand the version of HTML the document is written in for better interpretability. Doctype declarations are not HTML tags and belong at the very top of a document.
Structure and Declaration of Doctypes
- The
<!DOCTYPE>declaration should always be included at the top of the HTML document, before the<html>tag.
Section 2.1: Adding the Doctype
HTML 5 Doctype:
<!DOCTYPE html>
Section 2.2: HTML 5 Doctype Details
- HTML5 is not based on SGML (Standard Generalized Markup Language) and does not require a reference to a DTD (Document Type Definition).
- HTML5 Doctype declaration is simply:
<!DOCTYPE html>
Case Insensitivity
Per the W3.org HTML5 DOCTYPE specification, a DOCTYPE must consist of the following components, in this order:
- A string that is an ASCII case-insensitive match for the string
"<!DOCTYPE".
Therefore, the following DOCTYPEs are also valid:
- <!doctype html>
- <!dOCtyPe html>
- <!DocTYpe html>