HTML <! DOCTYPE
DOCTYPE is a short case of document type (document type).
! DOCTYPE is a document type tag, a document type declaration in a standard common tag language that is used in a web design to describe what version of XHTML or HTML you are using.
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
</head>
<body>
Document content ...
</body>
</html>
Try it out . . .
Browser support
All major browsers support slt;! DOCTYPE.
Label definition and instructions for use
<! The DOCTYPE is declared to be at the top of the document, before the label.
<! The DOCTYPE declaration is not an HTML tag;
In HTML 4.01, slt;! T he DOCTYPE declaration refers to DTD (document type declaration) because HTML 4.01 is based on SGML (Standard Generalized Markup Language standard common tag language). The DTD specifies rules for the markup language, ensuring that the browser renders the content correctly.
HTML5 is not based on SGML and therefore does not require a reference to DTD.
Tip: Always add a slt;! to your HTML documents! DOCTYPE is declared to ensure that the browser knows the document type in advance.
Tip: More details about DTD are available here: Introduction to DTD!
The difference between HTML 4.01 and HTML5
HTML 4.01 specifies three different types of D OCTYPE's statements are Strict, Transitional, and Frameset, respectively. There is only one type specified in HTML5:
HTML elements and Doctypes
See HTML elements and legitimate Doctype to see which Doctype each HTML element appears in.
Tips and comments
Note: slt;! The DOCTYPE.label does not end the label.
Tip: slt;! DoCTYPE is declared case insensoption.
Tip: Use W3C validation to check if you've written a legitimate HTML/XHTML document with the correct DTD!
Common DOCTYPE declarations
HTML 5
HTML 4.01 Strict
This DTD contains all HTML elements and properties, but does not include appearances or outdated elements such as font. Frame sets are not allowed.
HTML 4.01 Transitional
This DTD contains all HTML elements and properties, including ostentats or out-of-date elements such as font. Frame sets are not allowed.
HTML 4.01 Frameset
This DTD is the same as HTML 4.01 Transitional, but allows the use of frame set content.
XHTML 1.0 Strict
This DTD contains all HTML elements and properties, but does not include appearances or outdated elements such as font. F rame sets are not allowed. Structures must be written in standard-format XML.
XHTML 1.0 Transitional
This DTD contains all HTML elements and properties, including ostentats or out-of-date elements such as font. F rame sets are not allowed. Structures must be written in standard-format XML.
XHTML 1.0 Frameset
This DTD is the same as XHTML 1.0 Transitional, but allows the use of frame set content.
XHTML 1.1
This DTD is the same as XHTML 1.0 Strict, but allows you to add modules such as ruby support for East Asian languages.