r/javascript • • Aug 21 '18

Effectively supported in all browsers, JavaScript has its own form of media queries just like CSS.

https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
465 Upvotes

114 comments sorted by

View all comments

-34

u/StoneCypher Aug 21 '18

um, this actually is css, not javascript

0

u/[deleted] Aug 21 '18

[deleted]

-33

u/StoneCypher Aug 21 '18

Seems to work as expected

<html><head><style type="text/css">
  @media (min-width: 400px) { body { background-color: green; } }
  @media (max-width: 399px) { body { background-color: red; } }
</style></head><body>
  <p>hiya</p>
</body></html>

18

u/bearcherian Aug 21 '18

You should probably actually read the linked article and look at its examples. If you still think you're right, I sincerely hope you are not a professional web developer.

-16

u/StoneCypher Aug 22 '18

That's nice