Home  >  Article  >  Web Front-end  >  html标签究竟是否需要闭合?

html标签究竟是否需要闭合?

WBOY
WBOYOriginal
2016-06-07 08:43:212353browse

回复内容:

不耐烦可以跳到最后看结论。

Empty elements must either have an end tag or the start tag must end with />. For instance,
or


. See HTML Compatibility Guidelines for information on ways to ensure this is backward compatible with HTML 4 user agents.

CORRECT: terminated empty elements





INCORRECT: unterminated empty elements





w3.org/TR/xhtml1/
按XHTML的标准来说,
是不正确的
按HTML 4.01的标准来说,
是不正确的

根据 validator.w3.org/ 的检测结果:
Doctype: XHTML 1.0 Strict:
html标签究竟是否需要闭合?
是正确写法,而
是错误的。


Doctype: HTML 4.01 Strict:
html标签究竟是否需要闭合?

是正确写法,而
是错误的。

html标签究竟是否需要闭合?
W3C这个网站,声明的XHTML,也按照XHTML的标准来写的,正确。
html标签究竟是否需要闭合?
w3.org/TR/html401/sgml/ 这是W3C一个用了HTML 4.01的页面。
注意标签的写法,声明HTML4.01,也用的HTML 4.01的标准来写,正确。



没有谁对谁错的说法,关键看你声明的DOC TYPE。
你一旦声明了自己站队站哪边,你就得用谁的标准,不然才是错误的,像知乎这个就是错误的。 @林灿斌说:
知乎,声明的HTML5,可是用了
(HTML5下错误)
林说错了(妈蛋否定别人的否定真是拗口)
参考:
1、html标准的历史发展:HTML标签,闭合还是不闭合?
2、google-styleguide:
google-styleguide.googlecode.com
html标签究竟是否需要闭合? 需要。若果不闭合浏览器将自己判断在何处闭合,增加运行成本。 html标签究竟是否需要闭合?
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn