Doctype
Doctype is an HTML declaration used to instruct the browser about the HTML version used. This is included in the head section of the HTML file.
This declaration appears on the first line of the HTML document. The doctype declaration stands for the HTML version that the document is written in. This ensures the document is rendered consistently across various web browsers.
Without doctype, browsers may interpret the code differently, messing up the page’s appearance. Also, without specifying the HTML version, the browser may enter quirks mode, displaying the page using outdated rules.
Doctype declaration for HTML 4.01 was lengthy compared to HTML 5. Doctype declaration of HTML 4.01 requires the document type definition (DTD) that specifies the document’s legal elements and structural rules. DTD is required in HTML 4.01 as it is based on an older system called SGML (Standard Generalised Markup Language). Doctype declaration of HTML 5 does not require DTD as HTML 5 is not based on SGML.
The Doctype declaration for HTML 5 is <!DOCTYPE html>