什么是HTML5“元数据元素”?

时间:2012-04-30 19:05:24

标签: html html5

下午好,

我刚刚意识到这段代码validates是100%有效的HTML5:

<!doctype html>
<html>
  <title>asd</title>
  <script src="Js.js"></script>
  <script>alert('1');</script>
</html>

MDN声明<script>标记的允许父元素是:

  

接受元数据元素的任何元素,或接受短语内容的任何元素。 (source

我想知道有没有人知道元数据元素是什么意思? 措辞内容是什么意思?

2 个答案:

答案 0 :(得分:2)

  

属于元数据内容类别的元素会修改文档其余部分的表示或行为,设置指向其他文档的链接或传达其他带外信息。

     

属于此类别的元素包括<base><command><link><meta><noscript><script><style><title>

来源:https://developer.mozilla.org/en/HTML/Content_categories#Metadata_content

即使没有<head><body>,您的文档验证的原因是它们在HTML5中成为可选项。实际上,即使<html>是可选的,所以以下代码也是有效的HTML5:

<!doctype html>
<title>asd</title>
<script src="Js.js"></script>
<script>alert('1');</script>

答案 1 :(得分:2)

这是一个链接,用于定义元数据元素和措辞元素的含义。希望清除哪个是哪个。 http://www.w3.org/TR/html-markup/common-models.html#common.elem.metadata