gpt4 book ai didi

html - html 元素的第一个子元素是什么?

转载 作者:行者123 更新时间:2023-11-28 01:26:20 25 4
gpt4 key购买 nike

www.w3.org说:

The body element of a document is the first child of the html element

但是当我检查它不是 body 时,它是 head 元素:

document.getElementsByTagName("html")[0].firstElementChild
> <head>...</head>

我是不是误会了什么?因为我不认为 w3.org 可能是错误的。

最佳答案

这句话是指 body 属性返回的内容,而不是 html 元素的内容。

"The body element of a document is the first child of the html element that is either a body element or a frameset element."

这意味着 body 属性将返回常规页面的 body 元素,因为这是匹配其中一种类型的第一个(也是唯一一个)元素。

关于html - html 元素的第一个子元素是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31959043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com