Document Types, abbreviated as “doctypes” aid browsers in interpreting the version of HTML utilized within a document, enhancing its interpretability. Doctype declarations, distinct from HTML tags, are positioned at the document’s outset. This discussion elucidates the organization and declaration of diverse doctypes within HTML.
2.1 – Including the DOCTYPE
The <!DOCTYPE> declaration is essential and should be positioned at the outset of the HTML document, preceding the <html> tag. For Version 5 and above, refer to HTML 5 Doctype for comprehensive information on the HTML 5 Doctype.
<!DOCTYPE html>
2.2 – DOCTYPE HTML5
Unlike HTML5’s predecessor, SGML (Standard Generalized Markup Language), HTML5 does not necessitate a reference to a Document Type Definition (DTD).
HTML 5 Doctype declaration:
<!DOCTYPE html>
<!DOCTYPE html>
Case Insensitivity:
A DOCTYPE must include the subsequent components, in precise order:
- A string that is an ASCII case-insensitive match for the string “<!DOCTYPE”. Consequently, the subsequent DOCTYPEs are also deemed valid:
<!doctype html> <!dOCtYPe html> <!DOCtype html>