About This HTML Issue
The “stray start tag” terminology means the HTML parser encountered a <noscript> element in a location where no element should exist. This typically happens when the tag appears between </head> and <body>, after </body>, after </html>, or when a preceding markup error has caused the parser to close the <body> prematurely, leaving the <noscript> orphaned outside any valid container.
According to the WHATWG HTML living standard, <noscript> is permitted in two contexts: inside <head> (where it can only contain <link>, <style>, and <meta> elements) and inside <body> as a flow content element (where it can contain any content normally allowed in its parent). When found anywhere else, the parser treats it as a “stray” tag because it has no valid parent to attach to.
This matters because stray elements lead to unpredictable behavior across browsers. While most browsers attempt error recovery, the resulting DOM may not match your intentions. The fallback content inside a stray <noscript> may be silently discarded or rendered incorrectly, defeating its purpose of providing an accessible experience for users without JavaScript.
A common cause is markup generated by third-party tools like analytics platforms or tag managers. These snippets often instruct you to paste a <noscript> tag “immediately after the opening <body> tag,” but if pasted in the wrong location — or if a templating system places it outside <body> — the error occurs.
Another frequent cause is unclosed elements earlier in the document. If a tag above the <noscript> is malformed, the parser may implicitly close the <body>, making subsequent elements stray. In these cases, fixing the earlier error resolves the <noscript> issue as well.
How to fix it
-
Ensure
<noscript>is inside<head>or<body>— never between them, before<html>, or after</html>. -
When inside
<head>, only include<link>,<style>, or<meta>elements within it. -
When inside
<body>, use it like any other block-level element — it can contain paragraphs, divs, images, etc. -
Check for unclosed tags above the
<noscript>that might cause the parser to prematurely exit<body>.
Examples
Stray <noscript> after closing </body>
This is the most common scenario, often caused by pasting a tracking snippet in the wrong place:
<!-- ❌ Incorrect: noscript is outside body -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello</h1>
</body>
<noscript>
<p>Please enable JavaScript.</p>
</noscript>
</html>
Move it inside <body>:
<!-- ✅ Correct: noscript is inside body -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello</h1>
<noscript>
<p>Please enable JavaScript.</p>
</noscript>
</body>
</html>
Stray <noscript> between </head> and <body>
<!-- ❌ Incorrect: noscript is between head and body -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<noscript>
<iframe src="https://example.com/ns.html"></iframe>
</noscript>
<body>
<p>Content here.</p>
</body>
</html>
Place it at the top of <body> instead:
<!-- ✅ Correct: noscript is inside body -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<noscript>
<iframe src="https://example.com/ns.html" title="Tracking fallback"></iframe>
</noscript>
<p>Content here.</p>
</body>
</html>
Using <noscript> inside <head>
When placed in <head>, <noscript> can only contain <link>, <style>, or <meta> elements — not block content like <p> or <iframe>:
<!-- ❌ Incorrect: p is not allowed in noscript inside head -->
<head>
<title>My Page</title>
<noscript>
<p>Enable JavaScript!</p>
</noscript>
</head>
Either use only permitted elements in <head>, or move the <noscript> to <body>:
<!-- ✅ Correct: style is allowed in noscript inside head -->
<head>
<title>My Page</title>
<noscript>
<style>
.js-only { display: none; }
.nojs-message { display: block; }
</style>
</noscript>
</head>
Stray <noscript> caused by an unclosed element
Sometimes the real problem is an earlier unclosed tag. The parser implicitly closes <body>, making the <noscript> stray:
<!-- ❌ Incorrect: unclosed <div> causes parser confusion -->
<body>
<div>
<p>Some content</p>
<!-- missing </div> causes cascade of errors -->
<noscript>
<p>JavaScript is required.</p>
</noscript>
</body>
Fix the unclosed element, and the <noscript> error resolves:
<!-- ✅ Correct: div is properly closed -->
<body>
<div>
<p>Some content</p>
</div>
<noscript>
<p>JavaScript is required.</p>
</noscript>
</body>
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.