The viewport meta tag is one line that tells a phone to lay out your page at the width of its screen, instead of at a desktop width shrunk to fit. Most sites need exactly this: <meta name="viewport" content="width=device-width, initial-scale=1">. This guide explains what each value does, why switching off zoom fails accessibility rules and mostly does not work anyway, where its neighbour meta charset must sit, and what Next.js writes for you.
The free meta tag generator writes both lines at the top of the head and warns about user-scalable=no and a maximum-scale under 2.
Sources: MDN[1], the W3C ACT rule[6] and the HTML standard[3]. The site count is from the homepages listed further down.
What the viewport tag does
Chrome’s Lighthouse documentation says the same in plainer words: without the tag, “mobile devices render pages at typical desktop screen widths and then scale the pages down, making them difficult to read”[8]. Google lists the tag among the meta tags it supports: it “tells the browser how to render a page on a mobile device. Presence of this tag indicates to Google that the page is mobile friendly”[7].
The copy-ready version, with charset where it belongs:
<head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- title, description and the rest follow --> </head>
The tag does not make a layout responsive by itself. It sets the width the CSS sees; your CSS still has to fit that width. A fixed 1,200 px container will overflow a phone with or without it.
What each meta viewport value does
The content attribute is “a comma-separated list of one or more key-value pairs”[1]. These are the keys MDN documents, with their ranges:
| What it does (MDN) | Values | Use it? | |
|---|---|---|---|
| width | The (minimum) width of the layout viewport; sets the vw unit | 1 to 10000 px, or device-width | Yes: device-width |
| height | The (minimum) height of the viewport; sets the vh unit | 1 to 10000 px, or device-height | Rarely |
| initial-scale | Ratio between the device width and the viewport size | 0.0 to 10.0 | Optional: 1, never below 1 |
| minimum-scale | The minimum zoom level | 0.0 to 10.0 | Rarely; must not exceed maximum-scale |
| maximum-scale | The maximum amount to zoom in; iOS 10+ ignores it by default | 0.0 to 10.0 | Leave out; never below 2 |
| user-scalable | Whether the user can zoom; iOS 10+ ignores it by default | yes (default) or no | Never set to no |
| interactive-widget | How on-screen keyboards affect the viewport | resizes-visual (default), resizes-content, overlays-content | For apps with fixed footers or chat inputs |
| viewport-fit | Which part of a notched or rounded screen the page uses | auto, contain, cover | cover, with safe-area padding, for full-bleed designs |
You will also see shrink-to-fit=no in the wild; Microsoft and CNN sent it on 11 October 2026. It is not among the keys MDN documents today, so we leave it out of new pages.
initial-scale=1: needed or not?
Sources differ in emphasis, not in substance. MDN’s recommended setting is width=device-width alone. It calls initial-scale=1 “a common practice that’s usually unnecessary”: without it, the browser picks the starting zoom and “may zoom out when content overflows the viewport”. Add it “if overflowing content causes unwanted shrinking and you want the page to start at 100% zoom”[1]. Lighthouse recommends width=device-width, initial-scale=1, and fails a page whose initial-scale is below 1, because that can turn on double-tap-to-zoom, which “adds a 300 millisecond delay to any tap interactions”[8]. Our view: include initial-scale=1. It costs nothing and guards against a stray wide element zooming the whole page out.
Why you must not disable zoom
The most copied bad viewport is width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no. MDN’s warning is direct: disabling zoom “prevents people experiencing low vision conditions from being able to read and understand page content. Additionally, WCAG requires a minimum of 2× scaling; however, the best practice is to enable a 5× zoom”[1].
The rules behind that, from the W3C:
- WCAG 1.4.4 Resize Text (Level AA). “Except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality”[4].
- WCAG 1.4.10 Reflow (Level AA). Content works “without requiring scrolling in two dimensions”, where “320 CSS pixels is equivalent to a starting viewport width of 1280 CSS pixels wide at 400% zoom”[5].
- The ACT rule that tests it. “Meta viewport allows for zoom” fails a viewport whose
user-scalableisno, or whosemaximum-scaleis below 2. Its failed examples includemaximum-scale=1.0and evenmaximum-scale=1.5; it maps to 1.4.4 and, in its background notes, to 1.4.10[6].
And it mostly does not work. MDN notes that for maximum-scale, minimum-scale and user-scalable, “Browser settings can ignore this rule, and iOS10+ ignores it by default”[1]. The ACT rule adds that most modern mobile browsers ignore the setting by default or offer an accessibility option to allow zooming, so the users who still get stuck are those on older browsers[6]. A tag that fails an accessibility audit and is overridden by most phones is not worth keeping.
generateViewport page shows maximumScale: 1 and userScalable: false, which output maximum-scale=1, user-scalable=no. The docs present it “for completeness” and say manual configuration “is usually unnecessary as the default is sufficient”[9]. Do not paste that example as is.Two values worth knowing: viewport-fit and interactive-widget
viewport-fit=cover lets the page fill a screen with a notch or rounded corners. MDN: “The viewport is scaled to fill the device display. It’s highly recommended to use the safe area inset variables to ensure that important content doesn’t end up outside the display”[1]. Stripe and Apple both sent it on 11 October 2026.
interactive-widget decides what happens when the on-screen keyboard opens. The default, resizes-visual, shrinks only the visible area; resizes-content resizes the viewport itself; overlays-content resizes neither[1]. Walmart’s homepage sent interactive-widget=resizes-content. It matters for layouts with a fixed footer or a chat box that should stay above the keyboard.
<!-- Full-bleed layout on phones with a notch or rounded corners -->
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<style>
/* Keep content clear of the notch and the home indicator */
body {
padding: env(safe-area-inset-top) env(safe-area-inset-right)
env(safe-area-inset-bottom) env(safe-area-inset-left);
}
</style>
<!-- Let the on-screen keyboard shrink the layout, not just the visible area -->
<meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">The meta viewport 14 big sites send
We fetched these homepages on 11 October 2026 with a desktop Chrome user agent and read the viewport tag and the position of the charset tag. None disables zoom.
| Viewport content | Charset tag at byte | |
|---|---|---|
| bbc.co.uk | width=device-width, initial-scale=1 | 54 |
| theguardian.com | width=device-width,minimum-scale=1,initial-scale=1 | 435 |
| github.com | width=device-width | 258 |
| stripe.com | width=device-width, initial-scale=1, viewport-fit=cover | 40 |
| apple.com | width=device-width, initial-scale=1, viewport-fit=cover | 211 |
| walmart.com | width=device-width, initial-scale=1.0, minimum-scale=1, interactive-widget=resizes-content | 40 |
| microsoft.com | width=device-width, initial-scale=1, shrink-to-fit=no | 402 |
| edition.cnn.com | width=device-width,initial-scale=1,shrink-to-fit=no | 309,677 |
| shopify.com | width=device-width,initial-scale=1 | 1,986 |
| yahoo.com | width=device-width, initial-scale=1 | 122 |
| en.wikipedia.org | width=1120 | 627 |
| craigslist.org | width=device-width,initial-scale=1 | 36 |
| developer.mozilla.org | width=device-width, initial-scale=1.0 | 172 |
| nextjs.org | width=device-width, initial-scale=1 | 423 |
Two rows stand out. Wikipedia’s desktop page sets a fixed width=1120: it is a desktop layout, and the tag says so honestly rather than pretending to fit a phone. And two charset tags start well past byte 1,024, which is the next section.
Meta charset: utf-8, in the first 1,024 bytes
The viewport’s neighbour has two strict rules. The HTML standard says the value, if present, must be an ASCII case-insensitive match for utf-8, and “the actual character encoding used to encode the document must be UTF-8”. And placement: “The element containing the character encoding declaration must be serialized completely within the first 1024 bytes of the document.” There may be only one, and a document must not have both a charset tag and an http-equiv encoding declaration[3]. MDN puts the same rules in one line: the tag “must be located entirely within the first 1024 bytes of the document”[2]. Google recommends “Unicode/UTF-8 where possible”[7].
The standard also says when the tag is required: if a document “does not start with a BOM, and its encoding is not explicitly given by Content-Type metadata”, the encoding must be declared with a meta element[3]. That is why the two outliers above still display correctly. CNN’s charset tag started at byte 309,677 of a 5.8 MB page, and Shopify’s at byte 1,986, but both servers sent Content-Type: text/html; charset=utf-8, so the browser knew the encoding before reading a byte of HTML.
charset=utf-8 in the Content-Type header, and make <meta charset="utf-8"> the first element in the head. Then a cached copy, a saved file or a proxy that drops the header still decodes correctly.The viewport in Next.js
In the App Router you rarely write either tag. Next.js documents two default tags “that are always added even if a route doesn’t define metadata”: <meta charset="utf-8" /> and <meta name="viewport" content="width=device-width, initial-scale=1" />[10]. To change the viewport, export a viewport object, or a generateViewport function when it depends on the request. Both are “only supported in Server Components”, you cannot export both from one segment, and both were introduced in v14; a codemod moves viewport settings out of old metadata exports[9].
// app/layout.tsx. Next.js already writes these two tags on every page:
// <meta charset="utf-8" />
// <meta name="viewport" content="width=device-width, initial-scale=1" />
// Export a viewport only to change or extend them.
import type { Viewport } from "next";
export const viewport: Viewport = {
width: "device-width",
initialScale: 1,
viewportFit: "cover",
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "#ffffff" },
{ media: "(prefers-color-scheme: dark)", color: "#0b0b0c" },
],
// Do NOT copy maximumScale: 1 or userScalable: false from examples.
};The Viewport type also takes colorScheme and, less commonly, interactiveWidget[9]. For how the rest of a Next.js head reaches crawlers, including metadata streamed into the body, see the Next.js SEO guide.
How to check a page
Three commands show the viewport, where the charset tag sits, and whether the server declares the encoding:
# The viewport and charset tags a page sends, as a crawler sees them curl -sL https://www.example.com/ | grep -ioE '<meta[^>]+(viewport|charset)[^>]*>' # Where the charset tag starts, in bytes from the top (must end before 1024) curl -sL --compressed https://www.example.com/ | grep -b -o -iE '<meta[^>]*charset' | head -1 # Does the server already declare the encoding? curl -sI https://www.example.com/ | grep -i '^content-type'
In Lighthouse, the viewport check has moved into the “Optimize viewport for mobile” insight as of Lighthouse 13[8]. For the other head tags, the meta tags for SEO guide lists what Google supports and what it ignores, and the AI SEO checker runs a page through the wider set of on-page checks.
Questions people ask
What is the viewport meta tag?
It is a <meta name="viewport"> tag in the page's head that tells mobile browsers how wide to lay out the page and how to scale it. Without it, many phones lay the page out at a desktop width and shrink it to fit, so text is tiny. With width=device-width, the layout matches the screen.
What should the meta viewport be?
<meta name="viewport" content="width=device-width, initial-scale=1"> suits almost every site. MDN's recommended setting is width=device-width alone and calls initial-scale=1 usually unnecessary, while Lighthouse's example and Next.js's default include it. Either is fine. Do not add user-scalable=no or a maximum-scale below 2.
Is user-scalable=no bad for accessibility?
Yes. MDN says it prevents people with low vision from reading the page, and the W3C test rule for WCAG 1.4.4 fails any viewport with user-scalable=no or a maximum-scale under 2. MDN also notes iOS 10 and later ignore it by default, so it mostly fails audits without even working.
Does the viewport meta tag affect SEO?
Google lists viewport among the meta tags it supports and says the tag's presence indicates to Google that the page is mobile friendly. We found no Google statement that the tag itself is a ranking factor.
Where should meta charset go?
First in the head. The HTML standard says the element declaring the encoding must be serialized completely within the first 1024 bytes of the document, and its value must be utf-8. Placing <meta charset="utf-8"> as the first child of <head> meets both rules on any page.
Do I need a viewport tag in Next.js?
No. Next.js adds <meta charset="utf-8"> and <meta name="viewport" content="width=device-width, initial-scale=1"> to every route by default. To change the viewport, export a viewport object or a generateViewport function from a layout or page. Since Next.js 14 the viewport has its own export, separate from metadata.
