Window: devicePixelRatio property - Web APIs | MDN
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
related reading
- How big is 1px? | Dan Hollicktypefully.com
- <meta name="viewport"> HTML attribute value - HTML | MDNdeveloper.mozilla.org
- WebGL Resizing the Canvas.webglfundamentals.org
- Intersection Observer API - Web APIs | MDNdeveloper.mozilla.org
- An Introduction to the Browser Rendering Pipelinewebperf.tips
- Populating the page: how browsers work - Performance | MDNdeveloper.mozilla.org
- The Web Animation Performance Tier List | Motion Magazinemotion.dev
- Say precisely what you mean.index.how
- font-size CSS property - CSS | MDNdeveloper.mozilla.org
- will-change in CSSjakub.kr
- Zoom levels - OpenStreetMap Wikiwiki.openstreetmap.org
- Inside look at modern web browser (part 3) | Blog | Chrome for Developersdeveloper.chrome.com