Device pixel ratio and zoom
How many physical pixels per CSS pixel; also changes with browser zoom.
In one line
Can see your screen's sharpness factor, which also shifts when you zoom
How many physical pixels per CSS pixel; also changes with browser zoom.
Values like 1, 1.25, 1.5, 2, 2.625, 3 reveal retina screens, Windows scaling and the person's zoom level (50% to 500%). Zoom shifts DPR so it leaks accessibility settings.
What it can and can't do
What the user does: Nothing. It happens when the page loads or you zoom.
It can
- Check how many real pixels sit behind each page pixel
- Notice when you zoom in or out
- Pick sharper images to match
- Use the number as part of a fingerprint
It cannot
- See your exact screen size or model
- Tell for sure whether a change came from zoom or a new screen
- Change your zoom
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 1 | 2008-12-11 | None |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 18 | 2013-01-08 | RFP forces 1 |
| Safari | Supported | 3 | 2007-10-26 | None |
| Safari on iPhone | Supported | 2 | 2008-07-11 | None |
| Chrome on Android | Supported | 18 | 2012-06-27 | None |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | None |
How a site asks for it
| API | window.devicePixelRatio, matchMedia('(resolution: ...dppx)'), Sec-CH-DPR |
| Browser compat keys | api.Window.devicePixelRatio |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| How long it lasts | read fresh on every page load; nothing stored |
| How to take it back | none needed (no grant) |
| Inside an iframe | Readable from cross-origin iframes too (same values) |
Typical flow
- Page script reads the value
- No prompt is shown
Data you get
Shape: object
How often: static per session
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
devicePixelRatio | float | ratio | 0.5 to 5; common 1, 1.25, 1.5, 2, 3 | 0.01 to exact |
Technical limits
- Desktop DPR mixes OS scaling and browser zoom
The story
What it is
Tells a page how many real screen dots sit behind each page dot. It also changes when you zoom.
For you
You never see it. It is why text looks sharp on a Retina screen. When you press zoom in your browser the number changes and the page may redraw.
For makers
Makers use it to draw crisp canvases and send the right image size. It also leaks your zoom level, which is one more clue to tell your browser apart from others.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | A browser game sizes its drawing canvas by the ratio so pixel art stays sharp on Retina and does not crush a weak phone. | None named |
| creative | A design tool redraws lines and text when you zoom the browser so they stay crisp. | Figma |
| maps | A web map picks sharp or standard tiles and keeps labels readable. | Google Maps |
| shopping | A store gives a phone small high quality images and a desktop the larger ones. | None named |
| security | A fraud check notices a login from a window whose ratio never changes, a sign of an automated browser. | None named |
| ads | A tracking script reads the ratio and zoom to help recognise the same browser across sites. | None named |
Risks
- Leaks zoom level
- Fingerprint clue
What the platform says
- MDN: Window.devicePixelRatio. Explains how the ratio of real pixels to page pixels is used to draw sharp images and text.
Good uses and abuse
Legitimate uses
- Pick image density
Known abuse
- Zoom and accessibility inference
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 3 | Rough identifying entropy, when known |
A real example: LinkedIn
Collected as device pixel ratio. Read by the LinkedIn APFC fingerprint script (alleged by BrowserGate, partly confirmed by BleepingComputer).
Related capabilities
Related
- Browser zoom and default text size. Can guess your page zoom and your default text size from how pages lay out
Sources
How well checked: Based on official documentation.