I want to show a message that says “Please enable JavaScript to use this site” in the case that JavaScript is disabled, and nothing else to be displayed when JavaScript is disabled.
Please do not reply ONLY about the
<noscript>
tag or code like this.
Advertisement
Answer
Use <noscript>
, with a <style>
rule inside the <noscript>
that hides everything else using the body > *:not(noscript)
selector:
<head> <noscript> <style> body > *:not(noscript) { display: none; } </style> </noscript> </head> <body> <noscript> <p>Please enable JavaScript</p> </noscript> </body>