为什么可以在头部内添加文本 [英] Why is it possible to add text inside the head section

查看:63
本文介绍了为什么可以在头部内添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么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

4.2.1头元素

内容模型:
如果文档是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 of metadata content, of which no more than one is a title element and no more than one is a base element.
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.

这篇关于为什么可以在头部内添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆