Many search engines rank pages based on how mobile-friendly they are. Without a viewport meta tag, mobile devices render pages at typical desktop screen widths and then scale the pages down, making them difficult to read.
Setting the viewport meta tag lets you control the width and scaling of the viewport so that it's sized correctly on all devices.
How the Lighthouse viewport meta tag audit fails
Lighthouse flags pages without a viewport meta tag:
A page fails the audit unless all of these conditions are met:
- The document's
- The viewport meta tag contains a
contentattribute's value includes the text
Lighthouse doesn't check that
device-width. It also doesn't
check for an
initial-scale key-value pair. However, you still need to include
both for your page to render correctly on mobile devices.
Each PWA audit is weighted equally in the Lighthouse PWA Score, except for three manual audits: Site works cross-browser, Page transitions don't feel like they block on the network, and Each page has a URL. Learn more in the Lighthouse Scoring Guide.
How to add a viewport meta tag
Add a viewport
<meta> tag with the appropriate key-value pairs to the
of your page:
<meta name="viewport" content="width=device-width, initial-scale=1">
Here's what each key-value pair does:
width=device-widthsets the width of the viewport to the width of the device.
initial-scale=1sets the initial zoom level when the user visits the page.