May 03, 2021 HTML5
<! D oCTYPE is very important, it is a standard common markup language of document type declaration, through which the browser can understand the HTML specification that HTML5 documents are using, The DOCTYPE declaration is the starting point for the HTML5 document, which means that it must be on the first line of the HTML5 document!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
</head>
<body>
文档内容......
</body>
</html>
All major browsers support slt;! DOCTYPE.
<! 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, 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 slt;! to your HTML documents! DOCTYPE is declared to ensure that the browser knows the document type in advance.
HTML 4.01 specifies three different slt;! D OCTYPE's statements are Strict, Transitional, and Frameset, respectively. There is only one type specified in HTML5:
<!DOCTYPE html>
See HTML elements and legitimate Doctype to see which Doctype each HTML element appears in.
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!
<!DOCTYPE html>
This DTD contains all HTML elements and properties, but does not include appearances or outdated elements such as font. Frame sets are not allowed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
This DTD contains all HTML elements and properties, including ostentats or out-of-date elements such as font. Frame sets are not allowed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
This DTD is the same as HTML 4.01 Transitional, but allows the use of frame set content.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
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.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
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.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This DTD is the same as XHTML 1.0 Transitional, but allows the use of frame set content.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
This DTD is the same as XHTML 1.0 Strict, but allows you to add modules such as ruby support for East Asian languages.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">