How is code *between* the end of the HEAD tag and before the BODY tag processed?

后端 未结 2 432
慢半拍i
慢半拍i 2021-01-21 07:46

I have read that it is bad to do this, and outside the spec, but I have an error that is somewhat intermittent, and may be related. Just want to know if the general consensus i

2条回答
  •  滥情空心
    2021-01-21 08:23

    Content appearing between the end tag and start tag gets inserted just past the start tag, unless it's an element that does not belong in the body, in which case it will be inserted at the end of the head.

    Certain elements, like script, may appear in either the head or the body; script elements in that location will be inserted at the end of the head, unless the browser is already in the "in body" insertion mode, in which case they'll be placed in the body.

    See sections 8.2.5.4.4 The "in head" insertion mode, 8.2.5.4.6 The "after head" insertion mode and 8.2.5.4.7 The "in body" insertion mode of W3C HTML for further details. Note that implementations are not guaranteed to follow the spec, either owing to historical reasons, bugs, or deliberate decision to violate the spec, and this behavior should not be relied on.

提交回复
热议问题