About This HTML Issue
An <h2> that comes after a </body> or </html> end tag is stray, because the HTML parser accepts no more elements once the body has ended.
Once the parser reads </body>, only whitespace, comments and the closing </html> tag may follow. Any element after that point is a parse error. Browsers recover by treating the heading as part of the body again, so the page usually looks right and the mistake goes unnoticed. After </html> the validator also gives up: it reports "Cannot recover after last error" and checks nothing further down the page, so other errors stay hidden until you fix this one.
The </body> that ends the body is often not the one at the bottom of the page. A block of HTML included from a standalone file, such as a widget or a newsletter form, can bring its own <html>, <body>, </body> and </html> tags. The parser ignores the extra start tags, which the validator reports a few lines earlier, but it obeys the end tags, so the real body ends in the middle of the page. The <h2> that opens the next section is then the first element after that point. A template that closes the body before printing the rest of the content has the same effect.
Remove the <html>, <head> and <body> tags from the included block so only its content reaches the page, and keep one </body> and one </html> at the very end of the document. If the heading sits after the page's own </body>, move it inside the body.
Invalid example
<!DOCTYPE html>
<html lang="en">
<head>
<title>News</title>
</head>
<body>
<main>
<h1>News</h1>
<!-- Included newsletter block -->
<html>
<body>
<p>Subscribe to our newsletter.</p>
</body>
</html>
<h2>Latest articles</h2>
<p>New articles appear here every week.</p>
</main>
</body>
</html>
Valid example
<!DOCTYPE html>
<html lang="en">
<head>
<title>News</title>
</head>
<body>
<main>
<h1>News</h1>
<!-- Included newsletter block -->
<p>Subscribe to our newsletter.</p>
<h2>Latest articles</h2>
<p>New articles appear here every week.</p>
</main>
</body>
</html>
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.