Here's an alternative approach:
Incorporate the following code inside the head section of your HTML document after the regular stylesheet:
<link rel="stylesheet" href="jsdisabled.css" />
<script type="text/javascript">
document.write('<link rel="stylesheet" href="jsenabled.css" />');
</script>
The file jsenabled.css should contain:
#content { display:block; }
On the other hand, jsdisabled.css would include:
#content { display:none; }
Although this solution is effective, it may not pass validation tests.
You can use a noscript tag to apply styling that hides content for visitors with JavaScript disabled:
For example:
<noscript>
<style type="text/css">
#content { display:none; }
</style>
Content for non-JS users goes here.
</noscript>
<div id="content">
Main content appears here.
</div>
This method is preferred by some as it prevents flickering on the page when JavaScript is supported.