Viewport Meta Tag: What It Is, Why It Matters and How to Fix It
The viewport meta tag tells phones how wide to draw your page. See the exact tag to use, how we test it and how to fix a failed check.
Free to use 9 min read Updated Oct 2026
What Is the Viewport Meta Tag? The Short Answer
Quick answer: The viewport meta tag is one line in the head of your page that tells phones to draw the layout at the width of the screen instead of a zoomed out desktop canvas. Our report wants a meta tag named viewport in the rendered HTML.
- Pass: The rendered HTML contains a meta tag whose name is viewport.
- Fail: No meta tag named viewport turns up anywhere in the page.
- Fix: Add the standard tag once, inside the head of your shared template.
The standard tag is <meta name="viewport" content="width=device-width, initial-scale=1">. No account is needed.
What the Viewport Meta Tag Does on a Phone
Plenty of older pages were built for desktop screens, so a mobile browser that finds no instructions pretends the screen is much larger. MDN Web Docs uses a 980px virtual viewport as its worked example, and most phone browsers default to something close. The page is laid out on that canvas and then shrunk, leaving text tiny.
The tag switches that behaviour off. With width=device-width, the layout width equals the real device width in CSS pixels, so a flexible, mobile first design fills the screen and your CSS media queries finally see a true phone width. Desktop browsers ignore the tag, so a broken mobile page can look perfect on a laptop. It can't rescue a fixed 1200 pixel wrapper, which still overflows a narrow screen.
The tag in one line
<meta name="viewport" content="width=device-width, initial-scale=1">The name attribute says what the tag is, and the content attribute carries the instructions as comma separated pairs. Here width=device-width sets the layout viewport to the screen width in CSS pixels, the unit your stylesheet uses, which is why a high density phone reports a width in the hundreds and not its physical pixel count. The second pair, initial-scale=1, starts the page at 100 percent zoom.
Does the Viewport Meta Tag Affect SEO?
Not directly, so don't expect a traffic jump from one line of HTML. Under mobile-first indexing, Google Search Central says it mainly uses the mobile version of a page, so Googlebot smartphone meets whatever layout a phone would see. Without the tag that is a shrunken desktop layout, a poor mobile experience.
A missing viewport meta tag fails the Lighthouse audit, as does one with no width value, so Lighthouse, and tools built on it such as PageSpeed Insights, can flag it. In our report a missing tag is one failed check, which lowers your score. Our technical SEO checklist places it among the other basics.
Viewport Meta Tag Values and What They Mean
Most sites need only two. Our report reads none of them, so this advice comes from the specifications, with ranges and defaults in the MDN viewport meta reference.
Core values in one table
| Property | Allowed values | What it does | Advice |
|---|---|---|---|
width | 1 to 10000, or device-width | Sets the layout width. | Use device-width. |
initial-scale | 0.0 to 10.0 | Sets the starting zoom; 1 is 100 percent. | Use 1, never below. |
minimum-scale | 0.0 to 10.0 | Sets the lowest zoom. | Leave it out. |
maximum-scale | 0.0 to 10.0 | Sets the highest zoom. | Leave it out, or use 2 or more. |
user-scalable | yes or no | Allows or blocks pinch zoom; yes is the default. | Leave it alone. |
viewport-fit | auto, contain, cover | Fills screens with notches. | Use cover with safe area padding. |
interactive-widget | resizes-visual, resizes-content, overlays-content | Sets how the keyboard changes the layout. | Optional, support varies. |
The advice on initial-scale isn't unanimous. MDN's baseline example is width=device-width alone, with initial-scale=1 as an optional extra that stops browsers zooming out when content overflows. Lighthouse and Bootstrap still print both, so we treat the two value tag as the safe default.
Copy-paste examples
The first is the minimal form. The second suits notched phones, provided your CSS pads the edges with env(safe-area-inset-left) and its siblings. The third resizes the layout when the keyboard opens, but browser support is uneven, so test on real devices.
<meta name="viewport" content="width=device-width"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">How SEO Site Checker Tests Your Viewport Meta Tag
Our audit opens your URL in headless Chromium at a default desktop window size, with no phone emulation. After the load event it parses the rendered HTML and looks for the first meta element named viewport. If one exists the check passes; if not, it fails.
Exact rule: The check passes when at least one meta element with name="viewport", in lowercase, exists in the rendered DOM and carries a content attribute. It never judges the values inside content, so a tag with width=1024 or an empty content value passes just the same.
A pass shows a green tick and the line "This webpage is using a viewport meta tag." with the content in a code badge. A fail shows a red icon, "This webpage is not using a viewport meta tag." and the How to Fix button. There is no warning state.
A tag that JavaScript or a tag manager adds during loading still counts, though a much later one can be missed. Confirm the real values with Lighthouse or DevTools.
What passes
Placement does not matter, so a viewport meta element in the body instead of the head still passes. A theme and a plugin that each print a tag will both be present, and the report shows the content of whichever appears first, so the green badge can hide a conflicting second tag.
What fails
A page without a meta element named viewport fails. Browsers ignore case in meta names, but our audit matches lowercase exactly, so name="Viewport" fails here. A viewport tag with no content attribute at all may stop the report from completing on that page, so always include content. If a bot protection challenge page is served instead of your site, the check grades that page, which is why the report also carries a bot protection notice.
What the check does not test
We don't validate the settings in content, count duplicates, check the position in the head or detect blocked zoom. The values table and the mistakes list below cover those.
How to Add a Viewport Meta Tag, Step by Step
- Find the shared head. Look for the template that prints the head on every page, such as header.php, theme.liquid or a layout file.
- Add the tag once. Put the standard meta tag in head right after the charset tag, so the encoding is declared first. Our charset declaration guide covers that neighbouring line.
- Remove duplicates. Delete older tags, including plugin ones.
- Clear caches. Purge your page cache and CDN, because a stale head serves old markup.
- Verify and re-run. View the live source, confirm one tag, then run a fresh report. The badge should show the content string. If it does but the page still looks like a shrunken desktop, the tag is fine and the fault is fixed width CSS.
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Your page title</title>
</head>Viewport Meta Tag in WordPress, Shopify, Wix and Next.js
The table shows where the tag normally lives. It has to be in the HTML itself, because an Apache or Nginx header cannot set it.
| Platform | Where it lives | What to check |
|---|---|---|
| WordPress | header.php, near wp_head | Add it in a child theme and watch for plugin duplicates. |
| WordPress block themes | Printed by core | If the check fails here, look for custom head code that overrides the default. |
| Shopify | theme.liquid, inside head | If the check fails, suspect an old or heavily edited theme that dropped the line. |
| Wix, Squarespace | Managed by the builder | If the check fails, look for custom head code or an embed that overrides it. |
| Next.js App Router | Set automatically | Export a viewport object from layout to change it. |
| Plain HTML, Laravel Blade, PHP | The shared layout | Add it once so every page inherits it. |
Viewport Meta Tag Mistakes That Break Mobile Pages
- Blocking zoom. Setting user-scalable=no or a maximum-scale below 2 will block or cap pinch zoom, and the W3C meta viewport zoom rule from the ACT Rules Community Group treats both as failures of WCAG 1.4.4. Low vision users rely on pinch to zoom.
- iOS input zoom. Recent Safari on iOS ignores the restriction anyway. To stop zoom on a focused form field, set the input font size to at least 16px.
- A fixed width viewport. A value such as width=1024 or width=320 forces one layout on every phone, which often causes horizontal scrolling.
- Starting zoomed out. An initial-scale below 1 opens the page small, and Lighthouse flags it.
- Duplicate viewport tags. A theme prints one and a plugin another with different values.
- Typos and broken syntax. Common slips are name="viewpoint" or a missing comma.
- One template left behind. The home page has the tag, but the blog or checkout template uses another head file.
How to Check a Viewport Meta Tag on Any Page
- View page source. Search for viewport. Source shows raw HTML, so a JavaScript injected tag appears only in the DevTools Elements panel.
- Use Chrome DevTools and Lighthouse. The DevTools device toolbar previews phone widths. The Lighthouse viewport audit fails a page whose content has no width value or sets initial-scale below 1, and Lighthouse 13 moved it into the Optimize viewport for mobile insight.
- Try our tools. The Meta Tag Analyzer lists the viewport content of any URL, and the website screenshot tool has a mobile mode.
- Run the report again. A fresh run gives the final result.
How to Fix
The short version, the same steps you see when you click How to Fix in your report.
Why this fails: The rendered HTML of your page has no meta tag named viewport, so phones draw it on a wide desktop canvas and shrink it to fit. Our report only looks for the tag itself, and a tag that JavaScript adds while the page loads counts too.
How to fix it:
- Open the template that prints the head for every page, not a single page file.
- Add the tag once, right after the charset tag, using the code below.
- Remove any older or duplicate viewport tag, including one printed by a plugin or theme option.
- Save the file, then clear your page cache and CDN cache so visitors get the new head.
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">On WordPress, a child theme can print it on the head action. Remove this snippet if your theme already prints a tag.
add_action('wp_head', function () {
echo '<meta name="viewport" content="width=device-width, initial-scale=1">' . "\n";
}, 1);- WordPress: header.php or a child theme head hook.
- Shopify: theme.liquid, inside the head.
- Wix, Squarespace and similar builders: the platform manages the tag, so look for custom head code that removes it.
- Next.js App Router: the framework adds it by default.
- Plain HTML, Laravel Blade or PHP: the shared layout file. An Apache or Nginx header cannot set it.
Write the name in lowercase, never add user-scalable=no or a maximum-scale below 2 because that blocks zoom, and avoid a fixed pixel width or an initial-scale below 1.
Re-test: View the page source and confirm one viewport tag sits in the head, then run our free report again. The green badge prints the content it found.
Frequently Asked Questions
What is a viewport meta tag used for?
What is the correct viewport meta tag for a responsive website?
Where do I put the viewport meta tag?
What happens if my website has no viewport meta tag?
Does the viewport meta tag affect SEO?
Is it bad to use user-scalable=no in the viewport tag?
Why is my viewport meta tag not working?
See how your site scores right now
Paste your address into the free report, then use the How to Fix button on anything that needs work.
Free to use. Results in under a minute for most sites.