W3cubDocs

/CSS

@media.resolution

The resolution CSS media feature can be used to test the pixel density of the output device.

Syntax

The resolution feature is specified as a <resolution> value representing the pixel density of the output device. It is a range feature, meaning that you can also use the prefixed min-resolution and max-resolution variants to query minimum and maximum values, respectively.

Examples

HTML

<p>This is a test of your device's pixel density.</p>

CSS

/* Exact resolution */
@media (resolution: 150dpi) {
  p {
    color: red;
  }
}

/* Minimum resolution */
@media (min-resolution: 72dpi) {
  p {
    text-decoration: underline;
  }
}

/* Maximum resolution */
@media (max-resolution: 300dpi) {
  p {
    background: yellow;
  }
}

Result

Specifications

Specification Status Comment
Media Queries
The definition of 'resolution' in that specification.
Recommendation Initial definition.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
resolution media feature 29 12 8
8
3.5
Supports <integer> values only.
9 16
16
10 — 15
No
No
See bug 78087.
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
resolution media feature ≤37 29 8
8
4
Supports <integer> values only.
16
16
10.1 — 14
No
No
See bug 78087.
2.0

See also

© 2005–2020 Mozilla and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/resolution