How do we add a noscript section in HTML?


The task we are going to perform in this article is about how do we add a noscript section in HTML.

For browsers that do not support script tags or that have been configured by the user to deactivate script, HTML uses the <noscript> tag to show the text. Both the <head> and the <body> tags contain this tag.

Note − This element is only utilised by browsers that do not support scripting.

Syntax

Following is the syntax for nonscript

<noscript> Contents... </noscript>

Let’s dive into the following examples, to know more about adding a noscript section in HTML.

Example 1

In the following examples we are using the <noscript> tag.

<!DOCTYPE html>
<html>
<body>
   <script>
      document.write("Tutorialspoint!")
   </script>
   <noscript>The Best E-way Learning</noscript>
</body>
</html>

When the script gets executed, it will generate an output displaying the text that was written inside the script while leaving the text written inside the noscript tag.

Example 2

Considering the following example, where we are using the <noscript> tag.

<!DOCTYPE html>
<html>
<head>
   <title>HTML noscript Tag</title>
</head>
<body>
   <script>
      document.write("Hello JavaScript!")
   </script>
   <noscript>
      Your browser does not support JavaScript!
   </noscript>
</body>
</html>

On running the above script, it will generate an output consisting of the text written inside the script while leaving the text written inside the noscript on the webpage.

Updated on: 15-Dec-2022

411 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements