Viewport vs Screen Size
LIVE

Viewport vs Screen Size

Screen resolution is the total pixel count of your display — fixed hardware that never changes. Viewport size is the area your browser actually gives the page, and it shifts with every resize, zoom, or toolbar change.

Viewport
0 × 0
0 × 0
Live

Most people use these two terms interchangeably, and most people are wrong to do so. Screen size and viewport size are related, but they measure different things, conflating them leads to broken layouts, confused debugging sessions, and media queries that never seem to fire where expected. If you've ever written a responsive breakpoint that worked perfectly on your machine and fell apart on someone else's phone, this is probably why.

What screen size actually is

Screen size is the total number of pixels in your display, measured as width by height. A standard desktop monitor might be 1920×1080. A phone could be 1170×2532. This number is fixed at manufacture. It doesn't change when you open an app, resize a window, or zoom in and out. Your phone's spec sheet lists it. Your monitor's product page advertises it. It's a hardware fact, not a software behavior.

Knowing your screen resolution is occasionally useful — it tells you how many physical pixels your display has to work with. But for most web development work, it's the wrong number to design against. CSS doesn't respond to screen resolution. Media queries don't care about the pixel count printed on a box. The number that actually drives layout decisions is something else entirely.

What viewport size actually is

Viewport size is the area of the browser window that your page content actually occupies. It's expressed in CSS pixels, not physical pixels, and it changes constantly depending on the browser window size, the device orientation, browser zoom level, and how much space system UI elements like toolbars, address bars, and notches are taking up at any given moment.

This is the number that matters when you're writing CSS. When you set a media query at 768px, the browser checks the viewport width, not the screen resolution. When you use width: 100% on an element, that 100% refers to the viewport width, not the physical display width. Every responsive design decision you make is downstream of the viewport, not the screen.

The relationship between the two is mediated by device pixel ratio, or DPR. A phone with a 1170×2532 screen at DPR 3 reports a CSS viewport of roughly 390×844. The math is straightforward — divide the physical pixel count by the DPR — but the implication is important: the CSS layout has far fewer pixels to work with than the spec sheet suggests. Three physical pixels are being used to draw each CSS pixel, making text and images look sharp without changing how much layout space the page perceives.

Why they get confused

The confusion starts because the words "screen" and "viewport" sound like they should mean the same thing, and in casual conversation they often do. When someone says "what screen size are you targeting," they usually mean viewport width. When a client says "the design doesn't fit my screen," they're probably talking about the viewport area where content is visible, not the total pixel count of their display. The terminology overlap creates ambiguity that propagates through design specs, bug reports, and Slack conversations until someone builds a layout that targets the wrong number entirely.

It gets worse because browsers report both values in different contexts. Window.innerWidth gives you the viewport width. Screen.width gives you the screen resolution. A developer who grabs the wrong one and bakes it into a media query or a JavaScript calculation will get results that work on their specific setup and break everywhere else. I've debugged exactly this kind of bug on projects where someone hardcoded a breakpoint at 1080px because they measured their own monitor's resolution instead of the viewport, and then spent days confused about why the layout shifted on every other machine.

How browsers handle the difference

Modern browsers are designed to abstract away the gap between physical pixels and CSS pixels. This is what makes responsive design possible without maintaining separate stylesheets for every device ever manufactured. A single set of CSS rules can adapt from a 320px phone viewport to a 2560px desktop viewport because the browser scales everything in CSS pixel terms, regardless of the underlying hardware.

But the browser also has to account for things the spec sheet doesn't mention. Address bars, tab strips, status bars, notches, dynamic islands, rounded screen corners, and the home indicator bar on modern phones all take up physical space that reduces the available viewport. A phone with a 360px CSS viewport might drop to 320px when the address bar is visible and bounce back to 360px when it hides during scrolling. The screen resolution doesn't change. The viewport shifts by 40 pixels based entirely on browser chrome behavior.

Desktop browsers introduce their own complications. A maximized window on a 1080p display gives you a viewport close to 1920 pixels wide, minus whatever the browser's UI consumes. The same window at half-width gives you roughly 960 pixels. Windows display scaling further complicates this — a 4K monitor at 150% scaling might report a viewport width that feels like a 2560×1440 display, because the OS is rendering everything at a larger effective size. The screen resolution remains 3840×2160, but the viewport you're actually designing for is substantially smaller.

Where this breaks things in practice

The most common failure scenario is a media query that targets the wrong value. If you write a breakpoint at 1170px because you're designing for a phone with that physical resolution, it will never trigger on that phone — the viewport is closer to 390px. If you write a breakpoint at 1920px because you're testing on a desktop monitor at full screen, it will trigger unexpectedly on a 1440p display at full screen, where the viewport width is actually 2560px.

The second most common failure is assuming screen resolution equals layout space. High-DPR phones have screens that look enormous in raw pixel counts, but the CSS viewport is small. A layout that works beautifully at 1170px wide in a design tool will not work at 390px CSS pixels on the actual device unless you've built it to reflow, stack, and adapt at smaller widths.

The third failure is zooming. Browser zoom scales the viewport, not the screen resolution. A user who zooms in to 150% on a 1080px-wide viewport is now working with a 720px effective width. Layouts that depend on exact viewport measurements will break for these users unless the design accounts for zoom flexibility.

How to avoid these problems

Design against viewport width, not screen resolution. Use relative units — percentages, ems, rems, viewport units — instead of fixed pixel values wherever possible. Test at multiple viewport widths, not just the one your own device happens to have. The Device Dashboard on DevNestTools shows your live viewport size, screen resolution, and DPR side by side, updating in real time as you resize the window or rotate the device, which makes it easy to see the actual gap between what the spec sheet claims and what the browser is working with.

The rule of thumb is simple: spec sheet resolution tells you about the hardware. Viewport width tells you about the space your CSS has to work with. For any layout decision, only the second one matters.

Desktop Browser Window

Screen Resolution: 1920×1080

Viewport Size: 1860×980

Browser tabs, bookmarks bar, and the OS taskbar all eat into the viewport. The more UI chrome visible, the less room your page actually gets.

Modern Smartphone

Screen Resolution: 1080×1920

Viewport Size: 360×640

High pixel density phones and mobile browser scaling mean the CSS viewport is way smaller than the spec sheet resolution suggests. A 1080p phone might report a viewport of 360px.

Tablet Portrait Mode

Screen Resolution: 768×1024

Viewport Size: 768×936

Tablets usually give you more usable viewport space because browser chrome takes up a smaller proportion of the screen compared to phones.

Fullscreen Desktop Browser

Screen Resolution: 1920×1080

Viewport Size: 1920×1080

When the browser is fully maximized with no visible UI, the viewport can match the screen dimensions — but that's rare in practice since most people have tabs, bookmarks, or a taskbar visible.

Last updated: July 2026 | DevNestTools