我们是否仍然需要HTML5中的结尾斜杠? [英] Do we still need end slashes in HTML5?
问题描述
在HTML5中,我们是否仍然需要像XHTML那样的结束斜线?
< img src =some_image.png />
validator.w3.org没有抱怨,如果我放弃它,甚至没有警告。但一些在线文档似乎表明,对于img,link,meta,br等标签而言,仍然需要结束斜杠。
<
>无效元素
区域,基础,br,col,命令,嵌入,hr,img,输入,keygen,链接,元,参数,源,轨迹,
...
Void元素只有一个开始标记;不能为void元素指定结束标记。
据说HTML5中的解析并不严格,因此不会造成任何重大伤害。
In HTML5, do we still need the end slash like in XHTML?
<img src="some_image.png" />
validator.w3.org didn't complain if I dropped it, not even a warning. But some online documents seem to indicate the end slash is still required for tags such as img, link, meta, br, etc.
img
tags are Void Elements so they do not need an end tag.
Void elements area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr
...
Void elements only have a start tag; end tags must not be specified for void elements.
That being said it's not strict parsing in HTML5 so it won't do any major harm.
这篇关于我们是否仍然需要HTML5中的结尾斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!