# Viewport vs Screen Resolution vs Device Pixel Ratio

> Why an iPhone with a 1179×2556 screen lays pages out at 393×852. CSS pixels, device pixels and devicePixelRatio explained for web developers.

Canonical: https://ihatebugs.dev/guides/viewport-vs-screen-resolution
Last updated: 2026-10-17

Updated 2026-10-17.

**The viewport is the size a web page is laid out at, measured in CSS pixels. The screen resolution is how many physical pixels the display has. The device pixel ratio (DPR) is how many physical pixels draw one CSS pixel.** On an [iPhone 16](https://ihatebugs.dev/devices/iphone-16), a 393×852 CSS pixel viewport at a DPR of 3 fills a 1179×2556 pixel screen.

## CSS pixels: what your layout sees

Media queries, `width: 100vw`, `window.innerWidth` and every length in your stylesheet use CSS pixels. A CSS pixel is a unit of length, not a dot on the glass: browsers scale it so text stays readable at a normal viewing distance. That is why a phone with a very sharp screen still reports a narrow viewport around 360 to 440 pixels wide.

When you write `@media (max-width: 430px)`, you are asking about CSS pixels, and that is the number in our [screen size lists](https://ihatebugs.dev/screen-sizes).

## Device pixels: what the screen has

The screen resolution in a spec sheet counts physical pixels. Phones pack two to four physical pixels into each CSS pixel in each direction, so images and text look sharp. You almost never size layouts in device pixels.

## Device pixel ratio: the link between them

`window.devicePixelRatio` returns the ratio of physical pixels to CSS pixels ([MDN](https://developer.mozilla.org/docs/Web/API/Window/devicePixelRatio)). Multiply the viewport by it and you get the screen size:

| Device | Viewport (CSS px) | DPR | Screen (physical px) |
| --- | --- | --- | --- |
| [iPhone 16](https://ihatebugs.dev/devices/iphone-16) | 393×852 | 3 | 1179×2556 |
| [iPhone SE (3rd gen)](https://ihatebugs.dev/devices/iphone-se-3) | 375×667 | 2 | 750×1334 |
| [Galaxy S24](https://ihatebugs.dev/devices/galaxy-s24) | 360×780 | 3 | 1080×2340 |
| [iPad Air 11-inch](https://ihatebugs.dev/devices/ipad-air-11) | 820×1180 | 2 | 1640×2360 |

Some Android phones use fractional ratios such as 2.625, so the product is only approximately the panel's resolution.

## Why phones need the viewport meta tag

Without `<meta name="viewport" content="width=device-width, initial-scale=1">`, mobile browsers lay pages out at a wide virtual viewport (often 980 CSS pixels) and shrink them to fit, so text is tiny ([MDN](https://developer.mozilla.org/docs/Web/HTML/Viewport_meta_tag)). With it, the layout viewport matches the device's CSS width and your media queries behave as expected.

## Where the pixel ratio matters

- **Images:** serve 2× or 3× versions with `srcset` so photos stay sharp on high-DPR screens ([web.dev](https://web.dev/learn/design/responsive-images)).
- **Canvas:** scale a `<canvas>` backing store by `devicePixelRatio` or drawings look blurry.
- **Hairlines:** a `1px` border is one CSS pixel, which is three physical pixels wide at DPR 3.

## Test layouts at real viewports

Because layout depends on the CSS viewport, test at the widths your visitors actually have. The [Mobile Simulator](https://ihatebugs.dev/mobile-simulator) renders your page at each device preset's CSS viewport, and the [screen size lists](https://ihatebugs.dev/screen-sizes) show the most common widths.
