<noscript> tag in HTML
In some cases users disable scripts in their browser (user-agent) or the browser they’re using doesn’t support scripts. The no script can be used in the HTML document to instruct the browser what to do if scripting is turned off or is not supported. The noscript
element can be used in the <body>
of your HTML document. The noscript tag is not supported in XHTML.
Using noscript in the head
When using the tag in the head then it can only contain the following elements:
<link>
<style>
<meta>
Example of noscript
In the example below we’re trying to write to the document that the browser does support JavaScript. If JS is not supported then the noscript tag will instead show a message which says JavaScript is not supported:
<script>document.write("Your browser supports JavaScript.")</script>
<noscript>Sorry, your browser does not support JavaScript.</noscript>
Browser support and usage
The <noscript>
tag is well supported across all browsers. To use the tag it must have both the starting and ending tag.
Why do people disable JavaScript?
Users may disable JavaScript for privacy reasons, as a lot of tracking and analytical scripts use JavaScript. Other reasons could be to help phone battery life or if the user has slow internet connection they may turn off scripting. Also there a lot of browser extensions available to disable JavaScript running.
Further reading
- HTML Media Capture
- Scroll to text fragment: How to link & highlight any text on a web page
- A Guide to HTML Tables
Written by
Senior Interaction Designer and Co-Author to Tiny CSS Projects