I work on a 100% Javascript site that uses a CSS class on the body to explicitly hide everything (display:none), then enables blocks as needed (unusual yes, but I can't change the architecture).
I'd like to display a noscript message to users without js enabled, but we run into a CSS puzzle. noscript must exist within the body. Unlike other blocks on the page, the noscript element can't be forced to become visible, as far as I can tell. The weird thing is that when I select the noscript element with Webkit Inspector, it "claims" that the noscript element is visible. But no matter what, nothing appears on screen with js disabled.
I've done two test cases - one with standard noscript, and another with a hidden div. Either way, the hidden element remains hidden no matter what. My theory is that it's simply not possible to selectively display an element that's nested inside a hidden parent element (i.e. noscript within body).
Here's my simple test case.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style type="text/css" media="screen">
body{
display:none;
}
body noscript {
display:block;
visibility:visible;
color:black;
}
</style>
</head>
<body>
<p>Normal text</p>
<noscript>
<p>This is is noscript</p>
</noscript>
</body>
</html>
[Later: Example simplified for clarity]
Is this solvable? Thanks.
display:noneon the body? Can't you encourage whoever makes these decisions to let you have two divs, one visible by default to show the error message, the other hidden, and your js hides the first and shows the second the first thing it does? (Your js would have to show the body... so it may as well show a div instead). - Chris Nash