logo of Screenshot for Web
Free toolsPlaygroundDocsBlogPricing
LoginDashboard

Company

HomeFeaturesPricingBlogFacts

Screenshot Tools

Website ScreenshotsFull Page ScreenshotsScrolling ScreenshotsWebsite HistoryPDF Generation APIScreenshot API

Legal

Terms of UsePrivacy PolicyCookie PolicyCopyrightSecurity

Support

FAQSupportContact UsAPI Status
screen shot for web logo

No clutter. No distractions. Just clean, full-page screenshots with smart customization.

© 2026 HYDRANODE LTD. All rights reserved.

Screenshot for Web is operated by HYDRANODE LTD, a company registered in England and Wales, company number 15672526. Registered office: 124 City Road, London, London, England, EC1V 2NX.

FacebookInstagramLinkedInYouTube
  1. Home
  2. Blog
  3. Research

Device pixel ratio, viewport and user agent: what each one changes in a mobile screenshot

We changed one emulation setting at a time in headless Chrome and recorded what the page and server saw: what each setting does, and the set a mobile capture needs.

Screenshot for Web·October 21, 2026·7 min read

Sources

  1. Puppeteer: Viewport interface
  2. Puppeteer: Page.setUserAgent()
  3. Chrome DevTools Protocol: Emulation domain (Emulation.pdl)
  4. MDN: Viewport meta tag
  5. MDN: Window.devicePixelRatio
  6. MDN: Sec-CH-UA-Mobile
  7. Playwright: Emulation

How this article was made

Researched and drafted with AI assistance from the sources listed. The tests, captures and code were run by us on 21 October 2026 on an Apple M5 Mac (macOS 26.6, Node 22.21.1): the probe page with Puppeteer 24.11.1 on its bundled Chrome 138.0.7204.49 and with Puppeteer 24.11.1 and 25.15.0 on Chrome 156.0.8078.47, all with identical results; the five real sites with Puppeteer 24.11.1 on Chrome 156. Every number in the article comes from those runs.

Capture any page without ads, banners or chat widgets, free and without an account.

Try the free tools

More articles

  • News

    Puppeteer 25.19 stops print and dark mode emulation from cancelling each other

    Before Puppeteer 25.19.0, emulateMediaType and emulateMediaFeatures reset each other, losing print or dark mode. Our tests, the fix and a workaround.

    November 26, 2026
  • News

    Chrome 158 drops XSLT: what it does to screenshots of sitemaps and feeds

    We captured eight live sitemaps in Chrome 156 and Chromium 158. Styled pages turn into raw XML, a red warning bar is already in captures, and two fixes work.

    November 9, 2026
  • Research

    Chrome DevTools' full-size screenshot: where it fails on long and lazy pages

    We ran DevTools' full-size screenshot on six long pages: it stops at 16,384 pixels and misses content that appears on scroll. Here's why, and the fixes that worked.

    November 8, 2026

A mobile screenshot in headless Chrome is made of five separate settings, and each one changes something different. The viewport width decides which CSS layout the page uses. The device pixel ratio only decides how many pixels the image has. isMobile makes Chrome obey the page's viewport meta tag. hasTouch switches the touch media queries and events. The user agent changes what the server sends back, and setting only the string quietly breaks client hints. Change just one and you get a screenshot that is neither desktop nor mobile.

We tested this by changing one setting at a time on a probe page and on five real sites. Below are the results, three captures that show the failures, and a short Puppeteer script that sets all five consistently.

How we tested

On 21 October 2026 we served a small probe page from a local Node server. The page reports what the browser tells it: innerWidth, devicePixelRatio, screen.width, whether (max-width: 600px) and (pointer: coarse) match, navigator.maxTouchPoints, the user agent string and navigator.userAgentData.mobile. The server records the User-Agent and Sec-CH-UA-Mobile request headers it received. We served the page twice, once with <meta name="viewport" content="width=device-width, initial-scale=1"> and once without it.

The baseline was Puppeteer's desktop default: a 1280 × 800 viewport, deviceScaleFactor 1, isMobile and hasTouch false, and Chrome's own user agent. From there we changed one setting at a time, using the values from Puppeteer's built-in "iPhone 15 Pro" preset: a 393 × 659 viewport, deviceScaleFactor 3, isMobile and hasTouch true, and an iPhone Safari user agent string. Each run used a fresh browser context.

We ran the probe on three combinations: Puppeteer 24.11.1 with its bundled Chrome 138, Puppeteer 24.11.1 with Chrome 156, and Puppeteer 25.15.0 (the current release) with Chrome 156. All three gave identical values. Then we loaded five real pages with the same settings on Chrome 156: the first web page at info.cern.ch, Hacker News, GOV.UK, Bing and YouTube.

What each setting changes

Results from the probe page with the viewport meta tag. "Narrow CSS" means the (max-width: 600px) media query matched.

Changed aloneImage sizeinnerWidthNarrow CSSTouch (pointer: coarse)UA string says mobileSec-CH-UA-Mobile sentuserAgentData.mobile
Nothing (desktop)1280 × 8001280nonono?0false
deviceScaleFactor: 33840 × 24001280nonono?0false
Viewport 393 × 659393 × 659393yesnono?0false
iPhone user agent string1280 × 8001280nonoyesnot sentfalse
isMobile: true1280 × 8001280nonono?0false
hasTouch: true1280 × 8001280noyesno?0false
Android UA with metadata1280 × 8001280nonoyes?1true

Four things stand out.

The device pixel ratio changes the image, not the page. At deviceScaleFactor 3 the page still had a 1280-pixel layout and matched the same media queries; only devicePixelRatio and the image size changed. MDN defines the ratio as the number of physical pixels used to draw one CSS pixel, which is exactly what we saw: three times the width, three times the height, nine times the pixels. The PNGs grew less than ninefold. On four of the real pages they were 3.45 to 3.87 times larger; Bing, whose viewport is mostly a photograph, grew 5.6 times.

Two crops of the Hacker News header and first two stories. On the left, a capture at device pixel ratio 1 enlarged three times shows blocky, jagged letters. On the right, the same area captured at device pixel ratio 3 shows smooth, sharp text.

The viewport width is what switches the layout. Shrinking the viewport to 393 pixels was the only single change that made the narrow CSS apply. That is why a "mobile" screenshot taken at 1280 pixels wide with a phone user agent still shows the desktop design.

isMobile alone did nothing visible on a 1280-pixel viewport, apart from screen.width changing from 800 to 1280. Its effect appears when the page has no viewport meta tag, covered below. The Chrome DevTools Protocol describes the flag as emulating a mobile device, including the viewport meta tag, overlay scrollbars and text autosizing. In Puppeteer it does not turn on touch: maxTouchPoints stayed 0 until we set hasTouch. Playwright's documentation describes its own isMobile as covering both the meta tag and touch events, so the two libraries split the work differently.

Setting only the user agent string breaks client hints. With the iPhone string set through page.setUserAgent(), the server got an iPhone User-Agent header but no Sec-CH-UA-Mobile header at all, and navigator.userAgentData.mobile stayed false. Without an override, Chrome sent ?0. MDN describes Sec-CH-UA-Mobile as a low-entropy hint that is sent by default, without the server asking for it. A site that reads client hints rather than the string sees a browser that claims to be an iPhone in one place and says nothing in the other. Passing user agent metadata as the second argument fixed it: the header became ?1 and userAgentData.mobile became true. The DevTools Protocol's setUserAgentOverride documents that metadata as what is "sent in Sec-CH-UA-* headers and returned in navigator.userAgentData".

The viewport meta tag and isMobile

Most current sites declare width=device-width, so for them isMobile changes little. Pages without the tag are different. MDN explains that mobile browsers render such pages on a wider virtual viewport, giving 980 pixels as an example, and then shrink the result to fit the screen.

Chrome did exactly that. On our probe page without the meta tag, a 393-pixel viewport alone gave an innerWidth of 393 and the narrow layout. Adding isMobile changed innerWidth to 980, the narrow CSS stopped matching, and the screenshot showed a desktop-width page scaled down to a third of its size. The first web page at CERN, which has no viewport tag, behaved the same: its layout grew from 393 to 980 pixels wide and its text became tiny.

Two captures of the first web page at info.cern.ch at 393 by 659 pixels. With only the viewport set, the text is large and wraps to the narrow width. With isMobile added, the page is laid out 980 pixels wide and scaled down, so the text is very small.

The small version is the accurate one. It is what a phone shows for that page. If you only set the viewport, you get a screenshot no phone would produce.

The same flag can also zoom out pages that do have the tag. Bing declares a viewport, but at 393 pixels its layout was still 768 pixels wide and overflowed to the right. With only the viewport set, the screenshot cut that layout off at the right edge. With isMobile and hasTouch added, Chrome zoomed out until the 768-pixel layout fitted, which MDN notes browsers may do when content overflows. The hero image at the top of this article shows all three steps.

What the user agent changes

The user agent is the only setting the server sees before it sends any HTML, so it decides which page you get at all. Two of our five sites served something different:

SiteViewport, isMobile and hasTouch set, desktop UASame plus iPhone UA
YouTubewww.youtube.com, 1,284,704 characters of rendered HTMLredirected to m.youtube.com, 516,505 characters
Bingdesktop page zoomed out to 768 pixels widemobile page laid out at 393 pixels
GOV.UK, Hacker News, CERNsame pagesame page

GOV.UK and Hacker News served the same HTML to every user agent and adapted with CSS alone, so for them the viewport did all the work. For YouTube and Bing, a correctly sized viewport without a phone user agent gave a page that no phone ever receives.

The user agent has a cost in the other direction too. Setting only the iPhone string on a 1280-pixel viewport sent YouTube's mobile site into a desktop-sized window. Puppeteer's presets also carry fixed strings that age: the "Pixel 5" preset in Puppeteer 24.11.1 identifies as Chrome 99, and "iPhone 15 Pro" as iOS 17.5.

A mobile screenshot with all five settings

This script sets the viewport, device pixel ratio, isMobile, hasTouch and user agent with page.emulate(), then adds the client hint metadata that emulate() leaves out. We ran it with Puppeteer 24.11.1 and with Puppeteer 25.15.0 against Chrome 156. Puppeteer 25 documents the two-argument form of setUserAgent() as obsolete in favour of an options object, but it still works.

import puppeteer, { KnownDevices } from "puppeteer";

const device = KnownDevices["Pixel 5"];
const browser = await puppeteer.launch();
const page = await browser.newPage();

// Viewport, deviceScaleFactor, isMobile, hasTouch and the user agent string.
await page.emulate(device);
// Client hints: without this, Sec-CH-UA-Mobile is not sent and userAgentData.mobile stays false.
await page.setUserAgent(device.userAgent, {
  platform: "Android",
  platformVersion: "11",
  architecture: "",
  model: "Pixel 5",
  mobile: true,
});

await page.goto("https://www.bing.com/", { waitUntil: "networkidle2" });
console.log(
  await page.evaluate(() => ({
    layoutWidth: innerWidth,
    dpr: devicePixelRatio,
    touch: matchMedia("(pointer: coarse)").matches,
    uaDataMobile: navigator.userAgentData?.mobile,
  })),
);
await page.screenshot({ path: "bing-pixel5.png" });
await browser.close();

Output on both versions:

{ layoutWidth: 393, dpr: 3, touch: true, uaDataMobile: true }

The image was 1179 × 2553 pixels: the preset's 393 × 851 viewport times 3. We chose an Android preset on purpose. MDN's compatibility data lists neither Sec-CH-UA-Mobile nor navigator.userAgentData as supported in Safari on iOS, so pairing an iPhone string with Chrome's client hints creates a combination no real device has.

Which settings to change for which job

You wantChange
A sharper or larger image of the same layoutdeviceScaleFactor only
The page's responsive layout at a phone widthviewport, plus isMobile for pages without a viewport tag
Touch-only menus and controlshasTouch
The page a phone actually receivesall of the above, plus the user agent string and its metadata

Before trusting a mobile capture, check it from inside the page: innerWidth, devicePixelRatio, matchMedia("(pointer: coarse)") and navigator.userAgentData?.mobile should all agree with the device you meant to emulate. If one of them is off, the screenshot shows a page no phone would display.