>  기사  >  웹 프론트엔드  >  w3c是怎样规定<meta>标签的 到底有没有结束的斜杠?

w3c是怎样规定<meta>标签的 到底有没有结束的斜杠?

WBOY
WBOY원래의
2016-06-07 08:44:242294검색


哪种是更规范的写法

回复内容:

泻药
去查规范

HTML 4
The global structure of an HTML document
Start tag: required, End tag: forbidden


HTML5
4.2 Document metadata
Tag omission in text/html: No end tag.


所以:
第一种写法更贴近规范 这里有一个来自 StackOverflow 的回答,它比较详细地解释了你这个问题:

html - Are self-closing tags valid in HTML5?

In HTML 5, means , the start tag. It is not a "self-closing tag". Instead, certain elements are designated as having no end tag, for example
. These are collectively called void elements. The slash is just syntactic sugar for people who are addicted to XML. Using the slash in a non-void element tag is invalid, but browsers parse it as the start tag anyway, leading to a mismatch in end tags.
自闭合标签使用html5的doctype时不用写反斜杠。
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.