<noscript>

Content the browser shows only when JavaScript is turned off.

Display
none when JavaScript is enabled, inline when it is disabled
Closing tag
Required
Permitted content
In <body>: transparent content, with no nested <noscript>. In <head>: only <link>, <style>, and <meta>
On this page

Example

#
HTML
<p id="calculator">The course price calculator requires JavaScript.</p>
<noscript>
  <p>JavaScript is turned off. You can find all prices on the <a href="/pricing">pricing page</a>.</p>
</noscript>
<script>
  document.getElementById('calculator').textContent = 'JavaScript is working, the calculator is ready.';
</script>
Preview

When JavaScript works, the script replaces the text of the first paragraph, and the <noscript> content is skipped. You’ll see the <noscript> message only after turning off JavaScript in the browser settings.

Definition and usage

#

The <noscript> element contains fallback content for when scripts are disabled: by the user, by a blocking extension, or by a company computer’s settings. When JavaScript works, the browser skips the contents of this element entirely.

Placed in <body>, it can contain ordinary content, for example an explanatory message or a link to a version of the page that works without scripts. In <head> it can contain only <link>, <style>, and <meta> elements. That is useful when animations hide content until a script reveals it: without JavaScript it would stay invisible forever.

Remember that <noscript> won’t help when JavaScript is enabled but a script doesn’t load because the network failed or there’s a bug in the code. That’s why the most important content of a page should be available in the HTML itself, with scripts only enhancing it.

Syntax

#
Syntax
<noscript>
  Content for browsers without JavaScript
</noscript>

Attributes

#

This element has no attributes of its own. It supports the global attributes, such as class, id and hidden.

More examples

#
Fallback styles in the document head
HTML
<head>
  <style>
    .reveal { opacity: 0; transition: opacity 0.6s; }
    .reveal.visible { opacity: 1; }
  </style>
  <noscript>
    <style>
      .reveal { opacity: 1; }
    </style>
  </noscript>
</head>

A script adds the visible class when the element appears on screen. Without JavaScript nobody would add it, so the styles in <noscript> show the content right away.

Default CSS

#

Most browsers display this element with these default styles:

CSS
/* when JavaScript is enabled */
noscript {
  display: none;
}

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Don’t treat <noscript> as a backup plan for script errors. It works only when JavaScript is turned off.
  • In the message, say what exactly won’t work and where to find an alternative. A bare “Enable JavaScript” helps very little.
  • <noscript> elements can’t be nested inside one another.

Related entries

#

Spotted a mistake or missing an example? Write to us.