头部和身体标签之外可以包含哪些内容? [英] What content can be outside head and body tags?

查看:116
本文介绍了头部和身体标签之外可以包含哪些内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能看起来像一个奇怪的问题,但我正在构建一些读取HTML文件的脚本,并将内容分为2个部分,正文和头部,并且想知道是否可能存在其他我可能不知道的内容?

我知道的唯一的东西是< DOCTYPE> ,我想知道是否还有更多? / p>

解决方案

doctype声明并不完全符合词义。



头部 body 之外不存在任何内容(事实上,任何显示的内容应该只存在于 body 内)。然而,当你给它们奇怪或无效的标记时,浏览器可以创建一些非常古怪的DOM。以下是示例

此外, body ,依次,是 html 中仅有的两个可能的子元素,即根元素。


This may seem like a weird question, but i'm building some script that reads HTML files and i'm dividing the content to 2, body and head and was wondering if there could be other content i might not know of?

The only thing i know of is <DOCTYPE> and i was wondering if there could be more?

解决方案

The doctype declaration isn't exactly content in the sense of the word.

There isn't any content that is supposed to exist outside head and body (and in fact, any content that's meant to display should only exist inside body). Browsers can create some pretty wacky DOMs when you give them strange or invalid markup, however. Here's an example.

Also, head and body, in that order, are the only two possible children of html, the root element.

这篇关于头部和身体标签之外可以包含哪些内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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