- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <noscript> Tag
HTML Tags
HTML <noscript> Tag
The noscript tag holds content that only shows when JavaScript is turned off or fails to run. It is a fallback: a message, a link, or a simple version of something a script would normally build.
Very few visitors turn JavaScript off, but scripts can also fail to load on a bad connection or be blocked by a firewall. <noscript> is your note for those cases.
Syntax
html
<noscript>
Alternate content displayed if JavaScript is disabled.
</noscript>It has no attributes of its own.
Example
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>noscript Tag Example</title>
<script>
document.write("<p>JavaScript is enabled in your browser.</p>");
</script>
</head>
<body>
<noscript>
<p>Your browser does not support JavaScript or it’s disabled. Please enable JavaScript to view the full content of this page.</p>
</noscript>
</body>
</html>With JavaScript on, as it usually is, you see nothing from the <noscript> block. Turn JavaScript off in your browser settings and reload, and the message appears.
Where it can go
- In the body, it can contain normal content like paragraphs and links.
- In the head, it may only contain
<link>,<style>and<meta>tags, for example a stylesheet that is only needed without JavaScript.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
- A message saying "please enable JavaScript" is a last resort. Better: make the important content work in plain HTML, and use JavaScript to improve it.
- Analytics and tracking scripts often include a
<noscript>image tag; that is normal. <noscript>does not help when JavaScript is on but crashes. For that, the page itself needs to work without the script.
HTML <noscript> Tag exercises
Add a fallback message
Add a message that shows only when JavaScript is off: the paragraph Please turn on JavaScript.
Result
Check your answer to see it here.
