-1

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?

JackWM
  • 10,085
  • 22
  • 65
  • 92

1 Answers1

1

In the HTML5 parsing algorithm, no, except via injection by script. Some older browsers may move such elements though. For example see the thread that starts at http://lists.w3.org/Archives/Public/public-html/2007May/1066.html and in particular http://lists.w3.org/Archives/Public/public-html/2007May/1081.html

However, there is the case of what happens to an element that's normally in head, appears either before the <head> tag, or after the </head> tag but before the body element is created, for instance http://software.hixie.ch/.... In this situation, the element will be moved inside the head element.

Note that elements between the <head> and </head> tags can easily end up not inside the head element due to invalid mark up, for instance, http://software.hixie.ch/...

Alohci
  • 78,296
  • 16
  • 112
  • 156