[英]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 ofmetadata
content, of which no more than one is atitle
element and no more than one is abase
element.如果文档是iframe srcdoc文档或者标题信息可从更高级别的协议获得:
metadata
内容的零个或多个元素,其中不超过一个是title
元素,并且不超过一个是base
元素。
Otherwise: One or more elements ofmetadata
content, of which exactly one is atitle
element and no more than one is abase
element.否则:
metadata
内容的一个或多个元素,其中一个是title
元素,不多于一个是base
元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.