Skip to main content
HTML Validation

Stray start tag “noscript”.

About This HTML Issue

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:

  1. Position of <noscript>: The <noscript> tag should be placed correctly within sections where it is allowed.
  2. Nested Improperly: The <noscript> tag should not be placed inside other tags where it is not valid.

Correct Usage:

  1. Within <head>:

     <head>
         <title>Example Page</title>
         <script>
             // Some JavaScript code
         </script>
         <noscript>
             <style>
                 /* Alternative styling if JavaScript is disabled */
             </style>
         </noscript>
     </head>
  2. 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:

  1. 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>
  2. 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:

  1. Place <noscript> only within accepted sections (<head> or <body>).
  2. Avoid nesting <noscript> inside other tags improperly.

Last reviewed: September 19, 2024

Was this guide helpful?

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Ready to validate your sites?
Start your free trial today.