The tag is very simple, you may not care. But have you ever carefully understood the tag? W3cschool recommends using XHTML Transitional DTD, and many people obediently use Dreamweaver’s HTML document The default type is XHTML 1.0 Transitional. It has been used as a matter of course since then. People are really lazy as they grow up, and many things are subconsciously taken for granted. #The definition of
The declaration is located at the very front in the document, before the tag. This tag tells the browser what kind of document to use. HTML or XHTML specification. This tag can declare three DTD types, representing strict version, transitional version and HTML version based on
Framework
(If the markup in the document does not follow the DTD specified by the doctype declaration, this In addition to failing code verification, the document may not be displayed correctly in the browser)
Usage
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Copy after login
Copy after login
Analysis: In the above statement, Declares that the root element of the document is html, which is defined in a DTD with a public identifier defined as "-//W3C//DTD XHTML 1.0 Strict//EN". Browsers will know how to find a match for this public identifier. DTD. If not found, the browser will use the URL following the public identifier as the location to look for the DTD.
#- : Indicates that the organization name is not registered with the Internet Engineering Task Force (IETF). ) and the World Wide Web Consortium (W3C) are not registered ISO organizations.
- ##+: is the default, indicating that the organization name is registered. Specify the public text class, that is, the
object
type of the referenced - . The default is DTD.
##HTML: Specify the public text description, that is, the - object
type referenced. A unique descriptive name for the referenced public text. Can be followed by a version number. Defaults to HTML URL: Specifies the location of the referenced object. Strict: Exclude all representative
attributes and elements that W3C experts want to phase out - ##Three HTML document types
- HTML 4.01. Three document types are specified: Strict, Transitional and Frameset
##If you need clean markup to avoid clutter in the presentation layer, use the HTML Strict DTD type: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " http://www.w3.org/TR/html4/strict.dtd">
Copy after login
Transitional DTD can contain rendering attributes and elements that the W3C expects to be moved into style sheets. If the user is using a browser that does not support Cascading Style Sheets (CSS) and you have to use When rendering features of HTML, use the Transitional DTD type:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
Copy after login
Frameset DTD is used for documents with frames. The Frameset DTD is identical to the Transitional DTD, except that the frameset element replaces the body element:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" " http://www.w3.org/TR/html4/frameset.dtd">
Copy after login
Three
XML
If you need clean markup to avoid presentation clutter, use the XHTML Strict DTD type: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Copy after login
Copy after login
A Transitional DTD can contain rendering attributes and elements that the W3C expects to be moved into style sheets. If the user is using a browser that does not support Cascading Style Sheets (CSS) and you have to use the rendering features of HTML, use the Transitional DTD type:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Copy after login
Copy after login
Frameset DTD is used for documents with frames. The Frameset DTD is identical to the Transitional DTD, except that the frameset element replaces the body element: DTD corresponds to the standard that the document follows. For example, assuming that the document follows the xhtml 1.0 strict standard, the document's doctype declaration should reference the corresponding dtd. On the other hand, if the doctype declaration specifies an xhtml dtd, but the document contains old-style html markup, it is inappropriate; similarly, if the doctype declaration specifies an html dtd, but the document contains The xhtml 1.0 strict tag is also inappropriate.
If no valid doctype declaration is specified, most browsers will use a built-in default dtd. In this case, the browser will use the built-in dtd to try to display the tag you specify (but this is what happens when the page is poorly written).
I looked at JD.com, Taobao, and Blog Park, and they all use this one (I have always used this one): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Copy after login
Copy after login
但是发现百度跟谷歌用的是“”,就再仔细查了一下资料,发现HTML5也是直接用的这个,不过是因为 HTML 5 不基于 SGML,因此不需要对 DTD 进行引用,但是需要 doctype 来规范浏览器的行为(让浏览器按照它们应该的方式来运行)。
建议在以后都直接用“”,用的话就会开启浏览器的标准兼容模式,在标准兼容模式下,不能保证与其它版本(IE6之前的,直接忽略吧),的 Internet Explorer 保持兼容,文档的渲染行为也许与将来的 Internet Explorer 不同,但也请大家放心地使用吧~~
PS:XHTML 1就是HTML 4.01的XML化,是一种不向前兼容的格式。HTML 4.01 中的 doctype 需要对 DTD 进行引用,因为 HTML 4.01 基于 SGML。SGML规定了在文档中嵌入描述标记的标准格式,指定了描述文档结构的标准方法,目前在WEB上使用的HTML格式便是使用固定标签集的一种。
The above is the detailed content of Details about the tag in HTML. For more information, please follow other related articles on the PHP Chinese website!