Screen Resolution vs Viewport vs Pixel Ratio
Physical pixels, CSS pixels and the viewport explained with measurements from Chromium 141: what a 3x phone reports, which media queries match, and how a canvas drawn without devicePixelRatio scaling had five times as many blurred pixels as one drawn with it.
Physical, CSS and Viewport Pixels
A screen has three sizes worth knowing. The physical resolution is the panel's pixel grid. The CSS (logical) resolution is what pages lay out against, and screen.width reports it. The viewport is the part of the window the page actually gets, innerWidth wide. The device pixel ratio (DPR) links the first two: physical pixels per CSS pixel along each axis. We emulated five common setups in Chromium 141 and read the values a page sees:
| Setup | screen.width (CSS px) | DPR | Physical width | (min-width: 768px) | (min-resolution: 2dppx) |
|---|---|---|---|---|---|
| Phone 390 px @3x | 390 | 3 | 1,170 px | no | matches |
| Phone 390 px @2x | 390 | 2 | 780 px | no | matches |
| Tablet 820 px @2x | 820 | 2 | 1,640 px | matches | matches |
| Laptop 1440 px @2x | 1440 | 2 | 2,880 px | matches | matches |
| Desktop 1920 px @1x | 1920 | 1 | 1,920 px | matches | no |
A phone with a 1,170-pixel-wide panel still reports 390 CSS pixels and falls on the phone side of every width breakpoint; media queries never see physical pixels. To target sharp screens, use the resolution media feature (Chrome 29, Firefox 8, Safari 16 per MDN's compatibility data) or srcset for images.
Images and Canvas at High DPR
An image needs about DPR times its CSS width in real pixels to look sharp: 1,200 CSS pixels wide on a 2x laptop means a 2,400-pixel file. Let the browser choose with srcset; our image guide measured which file Chromium picks at 1x to 3x. SVG and icon fonts scale to any DPR on their own.
Canvas is the classic trap. We drew the same text and a 1-pixel line on two 120 × 60 CSS-pixel canvases at DPR 2. The one with a 120 × 60 backing store was stretched by the browser: 2,034 blurred, partly gray pixels and only 38 solid black ones. The one sized to 240 × 120 and scaled with ctx.scale(devicePixelRatio, devicePixelRatio) had 377 gray and 911 black pixels, crisp edges.
const r = window.devicePixelRatio || 1;
canvas.width = cssWidth * r;
canvas.height = cssHeight * r;
canvas.style.width = cssWidth + 'px';
ctx.scale(r, r); // draw in CSS pixels from here on
Breakpoints
Breakpoints are layout decisions, not device categories. Tailwind CSS's defaults are a common reference: sm 640 px, md 768 px, lg 1024 px, xl 1280 px and 2xl 1536 px, all minimum widths in CSS pixels. Set yours where your content starts to look wrong, and test in between them. The Screen Resolution Checker shows your screen, viewport and DPR and highlights which common breakpoint your window falls in; resize the window to watch it change.
Gotchas
- Mobile toolbars: on phones the address bar slides away as you scroll, so the viewport height changes mid-session.
100vhuses the larger size;svh,lvhanddvhgive the small, large and current heights and work in Chrome 108, Firefox 101 and Safari 15.4. - Zoom: in Chrome and Firefox, zooming in raises
devicePixelRatioand shrinks the CSS viewport, so a 1,440-pixel window at 200% zoom lays out like a 720-pixel one. MDN's compatibility data notes that Safari, on macOS and iOS, keepsdevicePixelRatiounchanged when the page is zoomed. - Fractional DPR: Windows scaling at 125% or 150% gives DPR 1.25 or 1.5, so a 1 px border can land between physical pixels and look blurry or uneven.
Try the tool
See your screen size, viewport, DPR, aspect ratio — live.
Frequently Asked Questions
Why is my viewport smaller than my screen?
What's the difference between DPR 1 and DPR 2?
How do I detect screen orientation changes?
Does zoom affect my layout?
Published Apr 15, 2026 · Updated Oct 14, 2026 by Derek Giordano
- [1]MDN browser-compat-data, Window.devicePixelRatio (Safari zoom note), checked live Oct 14, 2026 ↗
- [2]MDN, resolution media feature ↗
- [3]MDN, CSS length: small, large and dynamic viewport units (browser-compat-data 8.1.3) ↗
- [4]W3C, CSSOM View Module: devicePixelRatio and screen ↗
- [5]Tailwind CSS documentation, Responsive design: default breakpoints ↗