Why is it possible to add text inside the head section

邮差的信 提交于 2020-01-30 08:05:53

问题


Why does the text inside a head section of a HTML page get rendered in the DOM?

According to MDN the head section should do the following:

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?


回答1:


Text is not valid in the head tag.

The error correction of the browser moves the text from the head to the body

4.2.1 The head element

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.



来源:https://stackoverflow.com/questions/37437594/why-is-it-possible-to-add-text-inside-the-head-section

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!