Summary
This read-only property returns the ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device. This value could also be interpreted as the ratio of pixel sizes: the size of one CSS pixel to the size of one physical pixel.
There are no callbacks or events to listen to when this value changes (for example, if you drag the window between displays with different densities).
Syntax
value = window.devicePixelRatio;
Specifications
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) View Module The definition of 'Window.devicePixelRatio' in that specification. |
Working Draft | Initial definition |
Browser compatibility
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 49 | (Yes) | 49 | 11 | 41 | 9.1 |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 4.4 | (Yes) | ? | ? | all | 9.3 |
See also
- CSS
resolution
media query - PPK made some research on devicePixelRatio
Document Tags and Contributors
Tags:
Contributors to this page:
snizh,
libbymc,
mrenty,
jsx,
Jiang-Xuan,
darktrojan,
Chris_Chan,
Sebastianz,
fscholz,
Jonathan_Watt,
teoli,
Sole
Last updated by:
snizh,