noscript
The HTML <noscript> element provides alternative content when JavaScript is disabled or unavailable. Use it to keep an important message or route usable without scripts.
What you will learn
- What
noscriptdisplays when scripts cannot run - How its body and head forms differ
- How to make the fallback a useful path rather than a dead-end error
Basic body example
<main>
<h1>Product catalog</h1>
<noscript>
<p>JavaScript is required for filters. <a href="products/">Browse the full catalog</a>.</p>
</noscript>
</main>
When scripting is disabled, the content inside noscript is parsed and shown. When scripting is enabled, it is not shown as ordinary body content.
Head form
<head>
<noscript>
<meta http-equiv="refresh" content="0; url=/no-javascript.html">
</noscript>
</head>
Inside head, only content allowed in the document head is appropriate. Do not put ordinary paragraphs there. A redirect or other metadata fallback must be used carefully so it does not create loops or surprise users.
Do not hide the real content behind JavaScript
A fallback is useful, but the stronger design is to make essential content and navigation work without JavaScript whenever practical. Use scripts to enhance the experience, not to make every basic task impossible.
Common mistakes
- Showing only “Please enable JavaScript” without a useful alternative link or action.
- Putting body elements inside a
noscriptthat is placed inhead. - Assuming
noscripthandles script errors after JavaScript has already started. - Using a fallback that contradicts the current page or fails to explain what the user can do next.