0

Is it possible to use css @media query like this:

@media (javascript: disabled) { 
 body { color: red; } 
}

Or is there another way to do like this?

Phyo Wai LIn
  • 41
  • 1
  • 1
  • 1
  • 4
    Do it the other way around. Add a class that JS is availbale. – thetailor.de Sep 13 '21 at 08:16
  • 2
    Media Queries Level 5 has https://developer.mozilla.org/en-US/docs/Web/CSS/@media/scripting, but no browser support yet. – CBroe Sep 13 '21 at 08:17
  • 2
    A bit of basic research brings lots of approaches however, https://stackoverflow.com/q/4665748/1427878, https://stackoverflow.com/q/32514426/1427878, https://stackoverflow.com/q/35382266/1427878, https://stackoverflow.com/q/6181340/1427878 – CBroe Sep 13 '21 at 08:19

1 Answers1

4

For the most valid markup possible, you should be able to include this rule as part of a <noscript> block:

<noscript>
    <style type="text/css">
        body {
            color: red;
        }
    </style>
</noscript>
esqew
  • 42,425
  • 27
  • 92
  • 132