开发者

why google don't use DOCTYPE in its HTML? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_如何学C Closed 11 years ago.

I know DOCTYPE is important because some CSS rules need specific DOCTYPE. but why some sites like google.com don't specify DOCTYPE for their HTML?


The doctype is not necessary, it can be omitted:

http://www.w3.org/TR/html5-diff/

See chapter 2.2. The DOCTYPE:

"The HTML syntax of HTML5 requires a DOCTYPE to be specified to ensure that the browser renders the page in standards mode. The DOCTYPE has no other purpose and is therefore optional for XML. Documents with an XML media type are always handled in standards mode. [DOCTYPE]

The DOCTYPE declaration is < !DOCTYPE html> and is case-insensitive in the HTML syntax. DOCTYPEs from earlier versions of HTML were longer because the HTML language was SGML-based and therefore required a reference to a DTD. With HTML5 this is no longer the case and the DOCTYPE is only needed to enable standards mode for documents written using the HTML syntax. Browsers already do this for < !DOCTYPE html>."

Though I think it should be used to avoid confusions.


Using simply <doctype html> is enough for browsers to switch standart compliant mode. So there's no need to waste bytes for long doctypes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜