为什么可以在头部内添加文本 [英] Why is it possible to add text inside the head section
问题描述
为什么HTML页面的head
部分中的文本在DOM中呈现?
Why does the text inside a head
section of a HTML page get rendered in the DOM?
根据 MDN ,标头部分应执行以下操作:
According to MDN the head section should do the following:
HTML元素提供有关文档的常规信息(元数据),包括其标题以及指向其脚本和样式表的链接.
The HTML element provides general information (metadata) about the document, including its title and links to its scripts and style sheets.
如果在页面的头部放置一些文本,它将被放置在呈现的网页的正文部分.这不是奇怪的行为吗?
If you place some text inside the head section of the page, it will get placed in the body section of the rendered webpage. Isn't this weird behaviour?
推荐答案
head
标记中的文本无效.
浏览器的错误更正会将文本从head
移到body
The error correction of the browser moves the text from the head
to the body
内容模型:
如果文档是iframe srcdoc文档,或者可以从更高级别的协议获得标题信息:metadata
内容的零个或多个元素,其中title
元素不超过一个,而title
元素不超过一个.base
元素.
否则:metadata
内容中的一个或多个元素,其中一个元素是title
元素,而一个元素或多个元素是base
元素.
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.
Otherwise: One or more elements ofmetadata
content, of which exactly one is atitle
element and no more than one is abase
element.
这篇关于为什么可以在头部内添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!