window.devicePixelRatio works in Chrome 4+, Edge 12+, Firefox 18+, Safari 3.1+, Opera 11.6+, IE 11, and Samsung Internet 4+. See browser support and uses.

Prince Dewani
May 1, 2026
window.devicePixelRatio is a read-only JavaScript property defined in the W3C CSSOM View Module that returns the ratio of physical pixels to CSS pixels for the current display. It works in Chrome 4+, Edge 12+, Firefox 18+, Safari 3.1+ on macOS, Safari 3.2+ on iOS, Opera 11.6+, IE 11, Samsung Internet 4+, and Android Browser 2.1+.
This guide covers what devicePixelRatio is, the browsers that support it, how to use it, the production use cases, and the known limitations.
window.devicePixelRatio is a read-only property on the Window interface that returns a Number equal to the ratio of physical pixels to CSS pixels on the current display. The W3C CSSOM View Module defines it. A standard 96-DPI monitor returns 1, a Retina display returns 2, and modern flagship phones return 3 or higher.
Every modern desktop and mobile browser supports window.devicePixelRatio, with global coverage near 97%. Internet Explorer 11 is the only IE version with support, and a few legacy mobile builds report quirky values on Retina displays.
Chrome supports window.devicePixelRatio from Chrome 4 on Windows, macOS, Linux, ChromeOS, and Android. Chrome 1 to 3 did not expose the property. The value tracks both the display's physical density and the page zoom level, so a 200% zoom on a 96-DPI monitor returns 2 in Chrome.
Microsoft Edge supports window.devicePixelRatio from Edge 12 on Windows. The legacy EdgeHTML versions (Edge 12 to 18) read the same value the OS exposes, including fractional ratios like 1.25 and 1.5 from Windows display scaling. The Chromium-based Edge from Edge 79 on inherits the property on Windows, macOS, Linux, Android, and iOS through the Blink engine.
Firefox supports window.devicePixelRatio from Firefox 18 on desktop and on Firefox for Android. Firefox 2 to 17 did not expose the property and the read returned undefined. The value also reflects the page zoom level in Firefox, so the property is not a pure measure of the panel's physical pixel density.
Safari supports window.devicePixelRatio from Safari 3.1 on macOS and from Safari 3.2 on iOS, iPadOS, and iPod touch. Retina MacBooks return 2, the iPhone Plus and Pro Max series return 3 on the inner CSS grid, and standard non-Retina iMacs return 1. Pinch-zoom on iOS does not change the value.
Opera supports window.devicePixelRatio from Opera 11.6 on Windows, macOS, and Linux through the Presto engine, and from Opera 15 on through the Chromium base. Opera 9 to 11.5 did not support it. Opera Mobile shipped support from Opera Mobile 12, and Opera Mini exposes the property since the proxy renderer reports a fixed ratio of 1.
Samsung Internet supports window.devicePixelRatio from Samsung Internet 4 on Galaxy phones and tablets. The browser reads the value through the same Blink pipeline as Chrome on Android, so a Galaxy S-series flagship typically returns 3 or higher and a Galaxy A-series mid-range device returns 2 or 2.625.
The legacy stock Android Browser supports window.devicePixelRatio from Android 2.1 onwards, frozen at version 4.4 before Chrome for Android took over. The value follows Android's density buckets, so a hdpi device returns 1.5, an xhdpi device returns 2, and an xxhdpi device returns 3.
Internet Explorer 11 supports window.devicePixelRatio on Windows 7, Windows 8.1, and Windows 10. IE 5.5 through IE 10 do not expose the property and any read returns undefined. Microsoft has retired Internet Explorer, so use Edge, Chrome, or Firefox on Windows.
Note: window.devicePixelRatio reports different values across Retina Macs, Windows display scaling, and Android density buckets. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!
Read window.devicePixelRatio in any modern browser to get the physical-to-CSS pixel ratio, then size your canvas, WebGL buffer, or image asset against that number for a sharp render on HiDPI screens.
const dpr = window.devicePixelRatio || 1;
console.log(`Device pixel ratio: ${dpr}`);
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
const cssWidth = canvas.clientWidth;
const cssHeight = canvas.clientHeight;
canvas.width = cssWidth * dpr;
canvas.height = cssHeight * dpr;
ctx.scale(dpr, dpr);
const dprQuery = window.matchMedia(`(resolution: ${dpr}dppx)`);
dprQuery.addEventListener("change", () => {
console.log(`devicePixelRatio changed to ${window.devicePixelRatio}`);
});If the snippet logs 1 on a phone or Retina laptop you expect to be HiDPI, the page is likely running inside an embedded WebView with display scaling forced off, or in a proxy browser like Opera Mini that reports a fixed 1.
Anything that draws bitmap-style content reads window.devicePixelRatio to pick the right pixel budget, from canvas and WebGL apps to charting libraries and responsive image pipelines.
window.devicePixelRatio is a useful hint, but the value mixes display density, page zoom, and OS scaling into a single number, which makes it tricky to interpret in isolation.
In my experience, the bigger trap is treating window.devicePixelRatio as a static integer: a Windows laptop docked to a 1x external monitor reports 1, the same machine undocked at 150% reports 1.5, and zooming to 200% reports 3, all in the same session. Always feature-detect, round defensively, and listen for resolution changes through matchMedia.
All window.devicePixelRatio version numbers and platform notes in this guide come from these primary sources:
Did you find this page helpful?
More Related Hubs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance