Effective Use of the <noscript> Tag in HTML


I like to support (or at least acknowledge) users who have JavaScript disabled in their browsers. The <noscript> tag is a great way to provide alternative content or messages for these users. Here are the snippets that I use.

In the header:

	<noscript>
		<style>
			.scriptonly {
				display: none !important;
			}
		</style>
	</noscript>

Then, in the body, add the scriptonly class to any elements that should be hidden when JavaScript is disabled.

Date: 2025-11-01

Tags:  web

Share: