I have a document using XHTML Transitional. In the body I use a <noscript> tag with a <style type="text/css">.
I know that <style type="text/css"> is only allowed in the <head>, but still I need to have the CSS applied only if JavaScript isn’t detected.
How can I solve this problem, while still passing XHTML validation?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<noscript>
<div id="section-featured-nojavascript" class="section">
<style type="text/css">
#featured, #section-portfolio { display:none; visibility:hidden }
</style>
</div>
</noscript>
</body>
ERROR when validation using W3
document type does not allow element "style" here [XHTML 1.0 Transitional]
Don’t try to have a separate stylesheet. Use JS to add a
jsclass to the<body>(or to remove ano-jsclass). Then use that as part of a descendent selector in your main stylesheet.