1.doctype的概念?
html的doctype声明需要放在html的最开始,doctype的解释请参考“HTML <!DOCTYPE> 标签”。
2.为什么要用doctype?
doctype出现的目的是为了让浏览器知道是用“怪异模式(Quirks Mode)”还是“标准/严格模式(Standards Mode)”渲染html。实际上除了“怪异模式”和“严格模式”在其他浏览器中还有一种“类严格模式(Almost Standards Mode)”。各个浏览器会根据doctype的不同值开启不同的模式。详细信息可以参考“Activating Browser Modes with Doctype”。
之所以出现不同模式的原因是在IE和Netscape 兼容W3C标准之前,对CSS的实现有很大的差异,在IE和Netscape向W3C标准靠拢后,为了向前兼容,就出现了不同的模式。可以让web开发人员选择使用哪种模式作为标准。
不同的模式会影响浏览器在CSS布局、CSS解析和脚本(Script)这3方面产生的行为。
3.doctype该怎么写?
HTML5不在基于SGML,所以强烈建议将html的doctype声明为:“<!DOCTYPE html>”。这会让浏览器开启标准/严格模式。
4.doctype嗅探(doctype sniffing)
Doctype sniffing only applies to documents served as text/html. Documents sent as XML always activate the Standards layout mode. This includes documents sent as application/xhtml+xml. The consequence is that XHTML 1.0 Transitional documents are rendered in the Almost Standards mode when served as text/html under pretext of the Appendix C but in the Standards Mode when served asapplication/xhtml+xml.
5.HTML不再基于SGML?
The HTML5 standard specifies two serializations of HTML5: "html" and "xml". "xml" is a valid XML serialization (which in turn is a subset of SGML). "html" is not based on any specific serialization standard anymore, it has its own complete serialization. Herein lies the difference: HTML4 has a "sgml" serialization and "xml" serialization (called XHTML 1.0)
Of course HTML5 is for a large part based on HTML4, which is based on SGML and XHTML, which is based on HTML4 and XML.
Also see the history section of the HTML5 specification
参考:
TML <!DOCTYPE> 标签:
http://www.w3school.com.cn/tags/tag_doctype.aspa
为什么使用<!DOCTYPE HTML>:
“http://i.wanz.im/2010/05/28/why_doctype_html/”
Activating Browser Modes with Doctype:
https://hsivonen.fi/doctype/
HTML,XML,XHTML,HTML5和SGML简介:
http://lastplace.diandian.com/2012-10-04/sgml-the-sons
Quirks mode and strict mode:
http://www.quirksmode.org/css/quirksmode.html#link1
什么是“怪异模式”,什么是“标准模式”:
https://developer.mozilla.org/zh-CN/docs/Mozilla_Web_Developer_FAQ
相关推荐
DOCTYPE>并不是HTML标签,它声明web浏览器关于页面使用哪个 HTML 版本进行编写的指令。 在 HTML 4.01 中,<!DOCTYPE> 声明引用 DTD,因为 HTML 4.01 基于 SGML。DTD 规定了标记语言的规则,这样浏览器才能正确地呈现...
html doctype告诉浏览器使用什么样的html或xhtml规范来解析html文档,下面为大家详细介绍下,希望对大家有所帮助
DOCTYPE html PUBLIC.doc
写HTML代码的时候,第一行就要写DOCTYPE,而DOCTYPE一般都很长,大家也懒得去记,所以基本都是直接去复制以前写过的。不过今天了解到一种 DOCTYPE 的缩写.
样板 各种html doctype空模板
HTML !DOCTYPE 标签.docx
HTML 元素与合法的 Doctype.docx
html标题_DOCTYPE的含义 有关DOCTYPE标签的各种用法
HTML的!DOCTYPE是什么意思.zip
meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" /> ...
DOCTYPE> 声明位于文档中的最前面的位置,处于 <html> 标签之前。此标签可告知浏览器文档使用哪种 HTML 或 XHTML 规范。如果不写,可能会造
DOCTYPE html.xml
DOCTYPE html.docx
Doctype html.txt
DOCTYPE HTML PU.docx
DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> 好在现在的各种web开发工具都足够强大,支持插入模板代码,因此你并不需要把这又...
doctype.html