The resolution CSS media feature can be used to test the pixel density of the output device.
The resolution CSS media feature can be used to test the pixel density of the output device.
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.
<p>This is a test of your device's pixel density.</p>
/* 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; } }
| Specification |
|---|
| Media Queries Level 4 # resolution |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
resolution |
29 | 12 | 83.5Supports<integer> values only. |
9 | 1610–15 | 16 | 4.4 | 29 | 84Supports<integer> values only. |
1610.1–14 | 16 | 2.0 |
window.devicePixelRatioimage-resolution property
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/resolution