0

This snippet shows (replacement) content for users without Javascript, similar to the <noscript> tag.

<SCRIPT> document.write('<style type="text/css">#no_js{display:none;}</style>'); </SCRIPT>
<TAG id="no_js"> Content for users without Javascript </TAG>
<SCRIPT> var x=document.getElementById("no_js");x.parentNode.removeChild(x); </SCRIPT>
  • Line 1 hides the Content of line 2 with CSS.
  • Line 3 additionally removes the content - for Browsers without CSS but with Javascript.

I wonder whether line 3 is academic and can be left out.

Are there real world users around with no CSS but Javascript ?

Related posts:

Why not noscript tag

Avoid flickering

Community
  • 1
  • 1
shful
  • 394
  • 1
  • 5
  • 8
  • Why are you not just relying on – joseeight Jan 21 '14 at 13:08
  • This question appears to be off-topic because it is about user experience. – cimmanon Jan 21 '14 at 13:47
  • @joseeight: noscript tag may fail in special scenarios, see [link](http://stackoverflow.com/questions/2170484/shouldnt-we-use-noscript-tag) – shful Jan 21 '14 at 14:27

1 Answers1

1

There's no reason to assume anyone would intentionally disabled CSS for normal browsing. Historically, there were reasons people would have javascript disabled, such as security or performance, but that shouldn't be a concern with CSS. If there's a device using your site that doesn't have CSS, you certainly shouldn't plan on it using javascript.

m59
  • 43,214
  • 14
  • 119
  • 136
  • @Liam he said AND javascript enabled. I'll make that more clear. – m59 Jan 21 '14 at 13:10
  • 1
    `Screen readers for the blind and web-crawlers don't use CSS`. They are both aware of it to some extent, though. For example, `display: none` is recognized by screen readers, and Google notices some of your CSS. – ralph.m Jan 21 '14 at 13:22
  • Sceen readers seem to execute JS, see this survey [link](http://webaim.org/projects/screenreadersurvey3/#javascript) (and, btw, Googlebot surely does.) – shful Jan 21 '14 at 14:33
  • @shful I can't win. If I say one thing, someone will get upset that I didn't say the other. If I don't mention it, someone will comment that I should have ^ – m59 Jan 21 '14 at 14:40
  • @shful the point is, there's no standard practice involving the question you're asking. I assure you, you don't need to worry about it. – m59 Jan 21 '14 at 14:42