HTML Guide
An end tag for X has been found that does not correspond to a previous open tag. This usually happens when you close the same tag twice, for example:
<ul>
<li>item</li>
</ul>
</ul>
Related W3C validator issues
An </a> end tag has been found to violate nesting rules. <a> tags can’t include other <a> tags inside. Most probable cause is an unclosed <a> tag, like in this example:
<a href="one.html">Page 1
<a href="two.html">Page 2</a>
An end tag </code> has been found violating nesting rules. Check other errors in the same document related to the <code> element, and fix the unallowed nested elements.
A closing </body> tag has been found, but there are unclosed elements before it. For example this has an unclosed <section> element:
<body>
<section>
</body>
And end tag has been found that does not match the current open element. Check the context to fix the start and end tags.
An end tag has been found after the closing </body> tag, which breaks the expected HTML document structure.
Check out the document structure, a basic example follows:
<!DOCTYPE html>
<html lang="">
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
All HTML documents must start with a <!DOCTYPE> (Document Type Declaration), that informs browsers about the type and version of HTML used to build the document. In HTML5, this is simply <!DOCTYPE html> and must appear at the start of the document.
Here is an example of a minimal HTML document, including the Document Type Declaration at its start:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
A <head> start tag has been found in an unexpected place in the document structure. Check that the <head> section appears before the <body> section, and that is not duplicated.
The <head> section of an HTML document is the container of metadata about the document, and must appear before the <body> section. A common cause of this issue is duplicated <head> sections.
Here is an example of a minimal HTML document structure:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
A stray start tag <html> has been found in the document. As this tag defines the start of the whole HTML document, it should appear only once.
The “Stray start tag noscript“ error in the W3C HTML Validator indicates that the <noscript> tag has been used incorrectly or is placed in an invalid location within your HTML document.
The <noscript> tag is used to define alternative content for users who have disabled JavaScript in their browsers or for browsers that do not support JavaScript.
Common Causes:
- Position of <noscript>: The <noscript> tag should be placed correctly within sections where it is allowed.
- Nested Improperly: The <noscript> tag should not be placed inside other tags where it is not valid.
Correct Usage:
-
Within <head>:
<head> <title>Example Page</title> <script> // Some JavaScript code </script> <noscript> <style> /* Alternative styling if JavaScript is disabled */ </style> </noscript> </head>
-
Within <body>:
<body> <h1>Welcome to the Example Page</h1> <script> // Some JavaScript code </script> <noscript> <p>JavaScript is disabled in your browser. Please enable JavaScript for the full experience.</p> </noscript> </body>
Fixing the Issue:
-
Inside Existing Tags: Ensure the <noscript> tag is not placed inside other tags where it cannot be parsed correctly.
<!-- Incorrect --> <div> <noscript> <p>JavaScript is disabled in your browser.</p> </noscript> </div> <!-- Correct --> <noscript> <div> <p>JavaScript is disabled in your browser.</p> </div> </noscript>
-
Placement in Body or Head: Verify that the <noscript> tag is placed inside the <body> or <head> based on what content it’s providing a fallback for.
<!-- Incorrect (inside an illegal tag) --> <div> Some content <noscript><p>JavaScript is disabled in your browser.</p></noscript> </div> <!-- Correct --> <div>Some content</div> <noscript><p>JavaScript is disabled in your browser.</p></noscript>
Summary:
- Place <noscript> only within accepted sections (<head> or <body>).
- Avoid nesting <noscript> inside other tags improperly.
A <script> start tag has been found in an unexpected place in the document structure. Check that the <script> section appears within the <head> or <body> sections.
Here’s an example of a script inserted in the head of the document:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script>
console.log("Hello from the head");
</script>
</head>
<body>
<p></p>
</body>
</html>