What Is The HTML Noscript Tag?

What Is The HTML Noscript Tag

Date First Published: 10th November 2022

Topic: Web Design & Development

Subtopic: Web Development

Article Type: Computer Terms & Definitions

Difficulty: Medium

Difficulty Level: 6/10

Learn more about what the HTML noscript tag is in this article.

In HTML, the noscript tag defines alternative content to be displayed if scripting is disabled or not supported in the user's web browser. The alternative content must be defined within the <noscript> and </noscript> tags. The noscript tag can be placed inside the <head> and <body> tags, but if the tag is placed inside the <head> tag, the <noscript> tag can only contain <link>, <style>, and <meta> tags. This HTML tag is compatible with all popular web browsers.

This tag can contain any content of the site owner's choice. It is useful as nearly all websites use JavaScript and disabling JavaScript will often break the functionality of most websites. Sometimes, the reason why webpages are not working is that JavaScript is not supported by their web browser or they have disabled it and the user is unaware of that. By adding content to the noscript tag, it will notify users of when JavaScript is disabled and help them identify the possible reason why the functionality of the webpage is broken. It is recommended to add a notice to the page instead of preventing them from viewing the content of the page if JavaScript is disabled or not supported.

Example Of The Noscript Tag

An example of the noscript tag can be seen below:

<script>document.write("JavaScript is enabled")</script> <noscript> <div class="no-script-alert"> <span class="closebtn" onClick="this.parentElement.style.display='none';">×</span> <p>It seems as though JavaScript is disabled in your browser. JavaScript is required in order for this website to work.</p> </div> </noscript>

Result:

If JavaScript is enabled, you should see the 'JavaScript is enabled' text. Try disabling JavaScript in your web browser to see the noscript content. You may also see this warning at the top of the page below the navigation bar.


Feedback

  • Is there anything that you disagree with on this page?
  • Are there any spelling, grammatical, or punctuation errors on this page?
  • Are there any broken links or design errors on this page?

If so, it is important that you tell me as soon as possible on this page.