Definition and Usage
The <noscript> tag represents content that can replace scripts for users whose browsers do not support scripting or who have disabled scripting in their browsers.
A script refers to code that runs in the user's web browser (commonly called the "client") after a web page is loaded. The most common example is JavaScript.
On the other hand, if the browser supports scripting or scripting is enabled,
the <noscript> tag does nothing and is not displayed in the browser.
Purpos
Using the <noscript> tag allows you to provide different content for browsers that support scripting or have scripting enabled and those that do not.
Basic Examples
The <noscript> tag is used to provide alternative content for users whose browsers do not support scripting or who have disabled scripting when a web page uses scripts to implement content.
In this case, alternative content can be provided for two purposes.
- The first purpose is to inform users that content provided through scripts will not work or will not be displayed if scripting cannot be used.
- The second purpose is to provide alternative content when some features of content provided through scripts may be limited or only static content can be displayed if scripting cannot be used.
Purpose of Informing Users That Content Does Not Work or Is Not Displayed
<script>
/* If scripting cannot be used,
the content will not work or cannot be displayed */
</script>
<noscript>
<p>
This web page uses JavaScript to provide dynamically generated content.
However, JavaScript cannot be executed in your current browser.
</p>
</noscript>
The <script> tag is used to include scripts that are executed by the browser.
As shown in the example above, when scripts cannot be executed, you can use the <noscript> tag to display a notification to users.
Purpose of Providing Limited Functionality or Static Content
The following is an example of a web page that provides a slideshow. When scripting is unavailable, each image can be displayed individually instead of providing a slideshow.
<script>
/* The part that dynamically provides
a slideshow using JavaScript */
</script>
<noscript>
<img src="image1.jpg" alt="Image 1">
<img src="image2.jpg" alt="Image 2">
<img src="image3.jpg" alt="Image 3">
<!-- The part that displays each image individually -->
</noscript>
By using the <noscript> tag in this way, you can provide different content for cases where scripting is available and cases where scripting is unavailable.
Things to Keep in Mind
Since other elements or text inside the <head> element are not displayed on the screen, using them inside the <noscript> element when scripting is unavailable will also not display them on the screen. Therefore, when using <noscript> inside the <head> element, elements that can be used inside <noscript> cannot be elements that are displayed on the screen. The <link>, <style>, and <meta> elements are all elements that are not displayed on the screen.
Technical Summary
| Permitted parents | |
|---|---|
| Permitted content |
|
Implicit ARIA role |
No corresponding role |
Permitted ARIA roles |
No role permitted |
Browser Compatibility
| Tag |
Desktop Chrome
|
Desktop Edge
|
Desktop Firefox
|
Safari
|
|---|---|---|---|---|
<noscript>
|
1 | 12 | 1 | 3 |
Specifications
| Specification | |
|---|---|
<noscript>
|
HTML Standard #the-noscript-element |