flâneur — a map of the web's best reading

Window: devicePixelRatio property - Web APIs | MDN

developer.mozilla.org · 807 words · saved by 1 readers

The devicePixelRatio of Window interface 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. In simpler terms, this tells the browser how many of the screen's actual pixels should be used to draw a single CSS pixel. This is useful when dealing with the difference between rendering on a standard display versus a HiDPI or Retina display, which use more screen pixels to draw the same objects, resulting in a sharper image. You can use window.matchMedia() to check if the value of devicePixelRatio changes (which can happen, for example, if the user drags the window to a display with a different pixel density). See the example below. A double-precision floating-point value indicating the ratio of the display's resolution in physical pixels to the resolution in CSS pixels. A value of 1 indicates a class

Window: devicePixelRatio property - Web APIs | MDN Skip to main content Skip to search Window: devicePixelRatio property Limited availability This feature is not Baseline because it does not work in some of the most widely-used browsers. Want more browser support for this feature? Tell us why. Learn more See full compatibility The devicePixelRatio of Window interface 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

Explore this link on the map →

related reading