简体   繁体   English

为什么可以在head部分中添加文本

[英]Why is it possible to add text inside the head section

Why does the text inside a head section of a HTML page get rendered in the DOM? 为什么HTML页面的head部分内的文本会在DOM中呈现?

According to MDN the head section should do the following: 根据MDN ,负责人应该做以下事情:

The HTML element provides general information (metadata) about the document, including its title and links to its scripts and style sheets. HTML元素提供有关文档的一般信息(元数据),包括其标题以及其脚本和样式表的链接。

If you place some text inside the head section of the page, it will get placed in the body section of the rendered webpage. 如果您在页面的head部分放置一些文本,它将被放置在呈现的网页的body部分中。 Isn't this weird behaviour? 这不是奇怪的行为吗?

Text is not valid in the head tag. 文本在head标记中无效。

The error correction of the browser moves the text from the head to the body 浏览器的错误纠正将文本从head移动到body

4.2.1 The head element 4.2.1头部元素

Content model: 内容模型:
If the document is an iframe srcdoc document or if title information is available from a higher-level protocol: Zero or more elements of metadata content, of which no more than one is a title element and no more than one is a base element. 如果文档是iframe srcdoc文档或者标题信息可从更高级别的协议获得: metadata内容的零个或多个元素,其中不超过一个是title元素,并且不超过一个是base元素。
Otherwise: One or more elements of metadata content, of which exactly one is a title element and no more than one is a base element. 否则: metadata内容的一个或多个元素,其中一个是title元素,不多于一个是base元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM