DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
Menlo Park desk5 min

How to Fix Playwright Screenshots When the Mobile Viewport Meta Tag Is Missing

A missing viewport declaration can make mobile screenshots look like scaled-down desktop pages. Add width=device-width, enable Playwright mobile emulation, and check capture settings.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add <meta name="viewport" content="width=device-width"> to the page’s <head>, then capture it again with Playwright mobile emulation enabled. A narrow viewport alone does not guarantee mobile layout: Playwright’s isMobile setting controls whether the page’s viewport meta tag is taken into account. Set the viewport before navigation where possible, then check capture area and pixel scale if the result still looks wrong.

Why the screenshot looks desktop-sized

The viewport meta element gives the browser a hint about the page’s initial viewport. Without it, some mobile browsers may lay out a page against a wider virtual viewport—commonly around 980 CSS pixels—and scale that layout down to fit the screen. The result can have tiny text and controls, and narrow-screen CSS media queries may not behave as expected. MDN’s viewport meta tag guide explains the markup and its effect; MDN’s media-query guide covers responsive rules.

As an Amazon Associate I earn from qualifying purchases.

Playwright’s configured viewport dimensions and its mobile behavior are separate. The isMobile option determines whether the meta viewport is taken into account and enables touch events. A context with a phone-sized viewport but no mobile emulation may therefore fail to reproduce the mobile layout you expect. See the Playwright emulation documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix the page and configure mobile emulation

1. Add the viewport declaration

Put this inside the document’s <head>:

<meta name="viewport" content="width=device-width">

width=device-width is the core instruction: make the layout viewport match the device width. initial-scale=1 is commonly unnecessary. If overflowing content causes unwanted initial shrinking, investigate and fix the horizontal overflow rather than treating zoom settings as a substitute for responsive layout.

#1 Best Overall
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

2. Use a mobile context with an explicit viewport

A device descriptor is a convenient way to set a coherent group of device properties. You can also specify the relevant properties directly. This JavaScript example uses a mobile context and establishes the viewport before loading the page:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext({
    viewport: { width: 390, height: 844 },
    screen: { width: 390, height: 844 },
    isMobile: true,
    hasTouch: true,
    deviceScaleFactor: 1
  });
  const page = await context.newPage();
  await page.goto('https://example.com', { waitUntil: 'load' });
  await page.screenshot({ path: 'mobile.png' });
  await browser.close();
})();

Replace the example URL with the route you need to test. The dimensions are an explicit test viewport, not a claim that every phone uses that size. If you extend a Playwright device descriptor, put overrides after the spread so your chosen viewport or isMobile value wins:

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.
const { chromium, devices } = require('playwright');

const browser = await chromium.launch();
const context = await browser.newContext({
  ...devices['iPhone 13'],
  viewport: { width: 390, height: 844 },
  isMobile: true
});

Use a device descriptor available in the Playwright version installed in your project; device presets and browser support can vary by release and engine.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Make the change before navigation when possible

Prefer creating the context with the desired viewport and mobile settings before calling page.goto(). Playwright notes that changing the viewport after navigation can affect page layout and resets the screen size. If you need to control both, configure screen and viewport deliberately in the context. See the viewport API documentation.

Rank #3
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Check screenshot area and output scale

Once responsive layout is correct, distinguish layout problems from screenshot-output settings. Playwright documents these controls in its screenshot API.

Setting What it changes What it does not fix
fullPage: true Captures the full scrollable page instead of just the visible viewport. It does not make a desktop layout responsive.
scale: 'css' Produces output at CSS-pixel scale. It does not change the page’s responsive layout.
scale: 'device' Produces output at device-pixel scale; on high-DPI emulation, the image can have more pixels. It does not make a missing viewport declaration take effect.

For a useful comparison, keep the browser engine and project, device descriptor, isMobile, viewport width and height, device scale factor, navigation state, fullPage, and screenshot scale constant. Otherwise you may mistake a difference in capture area or pixel dimensions for a responsive-layout change.

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone

Troubleshoot a screenshot that still looks wrong

  • It still looks like a desktop page: inspect the loaded document’s actual <head> and confirm the expected route/document contains the viewport declaration. Then verify the context’s isMobile and viewport; changing screenshot scale is not a layout fix.
  • The viewport is narrow, but mobile rules do not apply: check mobile emulation, especially isMobile. Viewport dimensions alone are not equivalent to enabling mobile behavior.
  • Text is too small or the page seems scaled down: check whether the page lacks width=device-width and is being laid out against a wider virtual viewport. Also inspect horizontal overflow in the page rather than adding zoom restrictions.
  • The image is much taller than the screen: check whether fullPage is enabled. It captures the entire scrollable document.
  • The image dimensions differ although the layout looks alike: compare scale and deviceScaleFactor. Device-pixel output can be larger than CSS-pixel output on high-DPI emulation.
  • The screenshot changes after resizing: set the viewport before navigation when feasible. If resizing afterward is necessary, account for Playwright’s behavior of resetting the screen size and set both values intentionally.
  • Zooming is disabled as a workaround: remove user-scalable=no. It is not needed to stabilize a screenshot and can prevent users from zooming.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a clean capture without maintaining this browser configuration, ScreenshotNeo is a website screenshot API and MCP server. A single GET request returns a PNG, JPEG, WebP, or PDF. For example, this cURL request captures the target URL; see the ScreenshotNeo API documentation for the request options:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month, with no card required.

Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US

Frequently Asked Questions

Should I add initial-scale=1 to the viewport tag?

It is commonly unnecessary. Start with width=device-width; address horizontal overflow directly if it causes unwanted initial shrinking.

Does fullPage make Playwright render a responsive mobile layout?

No. It changes the capture area to the full scrollable page, not the responsive layout. Mobile behavior depends on the page markup and context settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.