Definition and Usage
The <resolution> CSS data types, used in media queries, denotes the density of pixels of an output device, its resolution. It is a <number> immediately followed by a unit of resolution (dpi, dpcm, ...). Like for any CSS dimension, there is no space between the unit literal and the number.
On screens, the length related to CSS inches, centimeters or pixels, not on physical values.
Even if all units represent the same resolution for the value 0, the unit may not be omitted in that case as it isn't a <length>: 0 is invalid and does not represent 0dpi, 0dpcm, nor 0dppx.
Units
-
dpi
- This unit represents the number of dots per inch. A screen typically contains 72 or 96 dpi; a printed document usually reach much greater dpi. As 1 inch is 2.54 cm,
1dpi ~= 2.54dpcm
. -
dpcm
- This unit represents the number of dots per centimeter. As 1 inch is 2.54 cm,
1dpcm ~= 0.39dpi
. -
dppx
- This unit represents the number of dots per
px
unit. Due to the 1:96 fixed ratio of CSSin
to CSSpx
,1dppx
is equivalent to96dpi
, that corresponds to the default resolution of images displayed in CSS as defined byimage-resolution
.
Examples
Here are some correct uses of <resolution> values:
96dpi Correct use: a <number> (here an <integer>) followed by the unit. @media print and (min-resolution: 300dpi) { ... } Correct use in the context of a media query.
Here are some incorrect uses:
72 dpi Incorrect: no spaces allowed between the <number> and the unit. ten dpi Incorrect: only digits must be used. 0 Incorrect: the unit can be omitted for 0 values only for <length>.
Compatibility
Desktop browsers
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 29 | 3.5 (1.9.1) [**] | 9 | 9.5 | Not supported |
dppx | 29 | 16.0 (16.0) | NA | 12.10 | NA |
Mobile browsers
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | Not supported | yes | NA | yes | Not supported |
dppx | NA | 16.0 (16.0) | NA | 12.10 | NA |