Obviously, the contents/tags within <head></head>
pair will be attached to Head element.
Is there any situation in which during the parsing of <body></body>
, some elements would be attached to Head element, instead of Body element?
Obviously, the contents/tags within <head></head>
pair will be attached to Head element.
Is there any situation in which during the parsing of <body></body>
, some elements would be attached to Head element, instead of Body element?
在 HTML5 解析算法中,没有,除非通过脚本注入。不过,一些较旧的浏览器可能会移动这些元素。例如,查看从http://lists.w3.org/Archives/Public/public-html/2007May/1066.html开始的线程,特别是http://lists.w3.org/Archives/Public/public- html/2007May/1081.html
但是,通常在 head 中的元素会发生什么情况,出现在<head>
标签之前,或者在</head>
标签之后但在创建 body 元素之前,例如http://software.hixie.ch/... . 在这种情况下,元素将被移动到头部元素内。
请注意,由于标记无效, <head>
and</head>
标签之间的元素很容易不在 head 元素内,例如,http://software.hixie.ch/...