Categories
HTML

How to detect if JavaScript is disabled with HTML?

Spread the love

Sometimes, we want to detect if JavaScript is disabled with HTML.

In this article, we’ll look at how to detect if JavaScript is disabled with HTML.

How to detect if JavaScript is disabled with HTML?

To detect if JavaScript is disabled with HTML, we add the noscript tag.

For instance, we write

<noscript>
  <style type="text/css">
    .pagecontainer {
      display: none;
    }
  </style>
  <div class="noscriptmsg">
    You don't have javascript enabled. Good luck with that.
  </div>
</noscript>

to add the noscript tag with the content that’s displayed when JavaScript is disabled.

Conclusion

To detect if JavaScript is disabled with HTML, we add the noscript tag.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *