Fast Links

How to fix the issue when noscript in head contains invalid HTML elements

How to fix the issue when noscript in head contains invalid HTML elements

Noscript in head contains invalid HTML elements issue means tha the URL contains a<noscript> tag in the <head> which includes invalid HTML elements.

Why It’s Important

The <noscript> tag defines an alternate content for users that have disabled scripts in their browser or have a browser that doesn’t support script.

Whilst it can be used in both the <head> and the <body>, when used inside the <head>, it must contain only <link>,<style>, and <meta> elements.

The inclusion of other HTML elements can be problematic for search engines crawlers that do not render JavaScript (i.e. most crawlers, most of the time), as the presence of other elements breaks the <head>, which may cause important tags (e.g. meta robots) to be missed.

How to Check the Issue?

This Issue will trigger for any internal URL that contains <noscript> in the <head>, with an invalid element (i.e. anything other than <link>,<style>, and <meta> elements).

To find it, check the source code. Access the page with your Chrome browser, right-click it, and pick “View page source” (this method differs in other browsers). This simple online tool https://codebeautify.org/source-code-viewer will also help you access the source code.

Here’s an example of invalid <noscript> in the <head>:

<head>
<noscript><h1>Why is it here?</h1></noscript>

</head>

How to Fix the Issue?

You will first need to establish what the <noscript> is and what it is doing. It may be possible to simply move the <noscript> out of the <head>, and into the <body>, where such elements are valid. All invalid elements should be removed from the <noscript>, if it is to remain in the <head>.

This is true even for Facebook tracking code, which is a common example we see triggering this rule. The Facebook tracking pixel consists of two parts: <script> and <noscript>. The latter is designed to track visitors who have JavaScript disabled in their browsers.

Unfortunately, they include an image element within the noscript, which breaks the <head> as described above, and this case is not immune simply because Facebook said you should do it.

There are two potential solutions for this specific Facebook problem:

– Just put the <noscript> bit in the body. If you trust random users on Stack Overflow, it will work just fine.
– Just delete the <noscript> bit entirely, and ignore the fact that a miniscule amount (~0.2%) of users might have JavaScript disabled and therefore won’t be included in your conversion tracking data.

Check Your Website for SEO Errors

No limits! Upgrade your account to crawl this domain
close