Media query

Why do you need the only keyword? Can’t you just do the following?

@media screen and (max-width: 480px) {
  body {
    font-size: 12px;
  }
}

And how do you know when to use max-width or min-width when writing a media query

It is not a requirement in newer browsers, but if there is a chance that a visitor may have an older browser that does not support media queries (properly or at all) the only keyword prevents that browser from applying the styles in that selector rule.


Aside

Given that we are well past Internet Explorer, Netscape, and any other non-WHATWG compliant browser we can almost give this keyword the boot. Still, it is not hurting anything (it’s ignored) so don’t go to any trouble trying to root it our of older stylesheets.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.