doctype
在w3schools中对doctype是这样解释的:
The declaration must be the very first thing in your HTML document, before the tag.
The declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.
In HTML 4.01, the declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
HTML5 is not based on SGML, and therefore does not require a reference to a DTD.
Tip: Always add the declaration to your HTML documents, so that the browser knows what type of document to expect.
理解
- 什么是doctype?
doctype 是一个指令,用于让浏览器知道该页面是用哪个版本的html编写的。
- 那么为什么浏览器要知道一个页面是什么版本的html呢?(为什么要使用doctype?)
因为浏览器对于页面有二种不同的呈现方式。
浏览器会根据一个html文档doctype声明来确定该使用何种方式呈现该页面
浏览器浏览器的标准模式与怪异模式的设置与区分方法:http://www.frontopen.com/1385.html