HTML validation · Head element
Script-injected elements close the head
A script adds a div to the head while the page loads. The raw HTML is fine, but the rendered head now contains an invalid element.
How this page is built
A small script at the end of the head of this page adds an empty, hidden div to the head while the page loads. The raw HTML is valid, but the rendered HTML has a div inside the head.
When the rendered HTML is read again, as Google does after rendering, the div closes the head. Only the analytics script follows it here.
Why it matters
Tag managers and third-party scripts often add elements to the page while it loads. If they add an image, iframe or div to the head, the rendered head contains an element that does not belong there.
Google processes the rendered HTML, so tags after that point can fall into the body, even though the source looks perfect.
How to check it
Compare the raw HTML with the rendered HTML, using the URL inspection tool in Google Search Console or a crawl tool with JavaScript rendering. Look for elements in the rendered head that are not in the source.
How to fix it
Configure scripts and tag managers to add elements to the body rather than the head, and load them after the important SEO tags so that any problem affects as little as possible.