views:

177

answers:

2

Using <noscript> inside of another tag seems to cause it to take on its own style (that is, none), and forces the text inside to take its own line (even if display:inline is set with CSS). Is there any way to avoid this, or a workaround to use instead?

Here is what I mean: http://www.webdevout.net/test?01I

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html lang="en">
  <head>
    <title>Test</title>
 <style type="text/css">
  p { font-family:sans-serif; font-size:12px;}
  noscript {display:inline !important;}
 </style>
  </head>
  <body>
    <p>This is some text<noscript> that should be displayed on the same line with the same style if JS if disabled.</noscript></p>
  </body>
</html>
A: 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html lang="en">
  <head>
    <title>Test</title>
 <style type="text/css">
  p { font-family:sans-serif; font-size:12px;}
 </style>
  </head>
  <body>
    <script type="text/javascript">document.write('<p>This is some text</p>');</script>
    <noscript><p>This is some text that should be displayed on the same line with the same style if JS if disabled.</p></noscript>
  </body>
</html>

Something like this should do what you want. You should of course use unobtrusive methods instead but I guess that´s above par for now.

anddoutoi
Is it? I thought he only wanted the stuff in noscript to be hidden with no js, 'this is' being intentionally left out.
D_N
Actually I don´t know what he wants cause I can´t see any added value. But my example will output 'This is some text' if scripts is supported and 'This is some text that should be displayed on the same line with the same style if JS if disabled.' if it´s unsupported. And this on the same line.
anddoutoi
A: 

Have you tried putting an element like a span inside the noscript tag, and then styling the span? It's a long shot, but might work.

Alternatively, get very specific with your selector and give that a shot. Something like #content p noscript { display:inline !important; } might work. But it might also be insoluble.

As a last resort, you could ditch the noscript tag and put in a span (or your element of choice) and give it a class of noscript -- then remove that first thing in your js.

D_N