<noscript>
The <noscript>
tag is used to provide alternative content to users whose browser does not support JavaScript or has disabled its execution.
It ensures a certain level of accessibility and a minimal experience, even in the absence of JavaScript-based functionalities. JavaScript.
This tag is particularly useful for sites where JavaScript is essential, such as single-page applications (SPA for Single Page Application: sites built with React, for example).
Structure and syntax of the <noscript>
tag
Basic structure and syntax
The <noscript>
tag is a container tag used to enclose alternative content.
It uses:
- An opening tag
<noscript>
; - A closing tag
</noscript>
.
This content is displayed only if JavaScript is disabled or not supported.
It is generally used like this:
<noscript>
[alternative content]
</noscript>
Usage example
Let's take a detailed example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of noscript tag</title>
</head>
<body>
<h1>Welcome to our site</h1>
<p>For a better experience, make sure JavaScript is enabled.</p>
<noscript>
<p>
<strong>Attention:</strong> JavaScript is disabled or not supported by your browser. Some functionalities will not be available.
</p>
</noscript>
</body>
</html>
In this example, the text "Attention..." is only displayed for users who cannot use JavaScript.
Attributes
The <noscript>
tag does not take any specific attributes; it can use all classic attributes such as: title
, class
, id
, etc.
Browser compatibility
Browser | Compatibility with <noscript> |
---|---|
Chrome | Yes |
Firefox | Yes |
Safari | Yes |
Edge | Yes |
Internet Explorer | Yes |