HTML - <noscript> Tag



Users who have deactivated scripts in their browsers or who are using a browser that doesn't support scripts will see an alternative content defined by the <noscript> tag. If the user's browser does not allow scripts, the text inside the <noscript> element will be displayed.

The <noscript> tag in HTML5 can be inserted into the <head> and <body> elements. It can only be applied to the <body> element in HTML4. If the <noscript> tag is placed in the <head> tag it must contain the <link>, <style>, and <meta> tags.

Syntax

Following is the syntax of <noscript> tag −

<noscript> Contents... </noscript>

Example

Let’s look at a basic example of the usage of the <noscript> tag.

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

On running the above code, it will generate an output consisting of the <script> tag text displayed on the webpage. As our browser supports scripting, it displayed the <script> tag text instead of the <noscript> tag text.

Example

Considering the following example, we are going to use the <style> element within the <noscript> tag.

<!DOCTYPE html>
<html>
<head>
   <style>
      h2 {
         color: #DE3163;
      }

      p {
         color: #7D3C98;
         font-style: verdana;
      }
   </style>
</head>
<body>
   <embed src="https://www.tutorialspoint.com/cg/images/logo.png" height="30" width="200"></embed>
   <h2>Welcome To The TutorialsPoint</h2>
   <p>The Best E-Way Learning</p>
</body>
</html>

When we run the above code, it will generate an output consisting of the text applied with CSS that is displayed on the webpage. When the user tries to disable the script, the text will change its CSS color.

html_tags_reference.htm
Advertisements