Skip to Content
Platform.Ontology

Device pixel ratio and zoom

How many physical pixels per CSS pixel; also changes with browser zoom.

Gets silentlyScreen and windowsScreenWeb browsersWhen the page loadsWhile you use it

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

BrowserStatusFirst versionReleasedNote
ChromeSupported12008-12-11None
EdgeSupported122015-07-29None
FirefoxSupported182013-01-08RFP forces 1
SafariSupported32007-10-26None
Safari on iPhoneSupported22008-07-11None
Chrome on AndroidSupported182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

APIwindow.devicePixelRatio, matchMedia('(resolution: ...dppx)'), Sec-CH-DPR
Browser compat keysapi.Window.devicePixelRatio
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)No
Needs a user gestureNo
How long it lastsread fresh on every page load; nothing stored
How to take it backnone needed (no grant)
Inside an iframeReadable from cross-origin iframes too (same values)

Typical flow

  1. Page script reads the value
  2. No prompt is shown

Data you get

Shape: object
How often: static per session

FieldTypeUnitRangePrecision
devicePixelRatiofloatratio0.5 to 5; common 1, 1.25, 1.5, 2, 30.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

TypeExampleApps
gamesA 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
creativeA design tool redraws lines and text when you zoom the browser so they stay crisp.Figma
mapsA web map picks sharp or standard tiles and keeps labels readable.Google Maps
shoppingA store gives a phone small high quality images and a desktop the larger ones.None named
securityA fraud check notices a login from a window whose ratio never changes, a sign of an automated browser.None named
adsA 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

Good uses and abuse

Legitimate uses

  • Pick image density

Known abuse

  • Zoom and accessibility inference

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits3Rough 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).

Sources

How well checked: Based on official documentation.

On this page