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
http://www.w3.org/tr/xhtml1/
按xhtml的标准来说,
是不正确的
按html 4.01的标准来说,
是不正确的
根据 http://validator.w3.org/ 的检测结果:
doctype: xhtml 1.0 strict:
是正确写法,而
是错误的。
是正确写法,而
是错误的。
doctype: html 4.01 strict:
是正确写法,而
是错误的。
w3c这个网站,声明的xhtml,也按照xhtml的标准来写的,正确。
http://www.w3.org/tr/html401/sgml/dtd.html 这是w3c一个用了html 4.01的页面。
注意标签的写法,声明html4.01,也用的html 4.01的标准来写,正确。
没有谁对谁错的说法,关键看你声明的doc type。
你一旦声明了自己站队站哪边,你就得用谁的标准,不然才是错误的,像知乎这个就是错误的。@林灿斌说: 知乎,声明的html5,可是用了
(html5下错误)
林说错了(妈蛋否定别人的否定真是拗口)
参考:
1、html标准的历史发展:html标签,闭合还是不闭合?
2、google-styleguide:
http://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml?showone=document_type#document_type
需要。若果不闭合浏览器将自己判断在何处闭合,增加运行成本。