Guide : Viewport Meta Tag
Ce que the viewport meta tag fait, pourquoi it rend responsive design fonctionner on mobile, the correct configuration, the attribute référence, and Erreurs fréquentes.
Langues
The viewport meta tag — <meta name="viewport" content="width=device-width, initial-scale=1"> — hints to le navigateur to size the layout viewport to the device's width in CSS pixels au lieu de a legacy ~980px fallback some mobile navigateurs utiliser. Sans it, phones peut render lune page at que wider fallback and shrink it, producing tiny text, horizontal scroll, and responsive breakpoints que may pas appliquer as intended. It's pas a ranking factor itself, but its presence is un of the choses Google documents as indicating mobile-friendliness, and its absence is a classic ergonomie mobile échec. Jamais force user-scalable=aucun or a restrictive maximum-scale — it fails the W3C's accessibility conformance rule pour zoom and peut lock out low-vision utilisateurs, though navigateurs peut override it (iOS 10+ ignores it by par défaut). Tester it with Lighthouse or PageSpeed Insights: Search Console's Ergonomie mobile report and the Mobile-Friendly Tester were retired December 1, 2023.
Evidence for this claim The viewport meta tag lets authors control viewport width and scaling so responsive layouts render at device width. Scope: Browser viewport behavior. Confidence: high · Verified: MDN: Viewport meta tag Evidence for this claim Pages should not disable browser zoom because users must be able to enlarge content for accessibility. Scope: WCAG resize-text requirement and viewport guidance. Confidence: high · Verified: W3C WAI: Understanding Resize TextTL;DR — The viewport meta tag is un line in votre page’s
<head>que indique phones and tablets to render votre page at the screen’s réel width au lieu de pretending it’s a desktop monitor. Sans it, votre page montre up tiny and vous have to pinch and scroll sideways to lire it. The line vous vouloir is<meta name="viewport" content="width=device-width, initial-scale=1">.
Ce que the viewport meta tag is
Quand smartphones premier got web navigateurs, la plupart websites were construit pour desktop screens. So nombreux phone navigateurs cheated: sans a viewport tag, they’d fall back to a fixed ~980 pixel wide layout — desktop-ish — lay lune page out at que width, alors shrink the whole chose bas to fit the phone. Le résultat was a readable-shaped page que was façon aussi petit to en réalité lire, with text vous had to pinch-zoom and content que spilled off the sides.
The viewport meta tag turns que off. It’s a unique line vous put in the
<head> of votre page:
<meta name="viewport" content="width=device-width, initial-scale=1">width=device-width indique le navigateur “lay ce page out at ce device’s screen
width, mesuré in CSS pixels” (pas necessarily the même as its raw hardware-pixel
count on a high-density screen), and initial-scale=1 dit “and don’t zoom in or
out quand lune page premier loads.” That’s it. Copy que line, paste it near the top of
votre <head>, fait.
Pourquoi c’est important
Two raisons:
- It rend votre page readable on a phone. With the tag, text is legible sans zooming and content fits the screen. Sans it, vous obtenir the shrunk-down, tiny-text, horizontal-scroll experience.
- It’s ce que rend “responsive design” en réalité fonctionner. Si votre site uses modern responsive CSS (layouts que adapt to screen size), ceux rules are meant to kick in fondé on le navigateur’s réel screen width. The viewport tag is ce que indique it que width. Sans it, votre responsive breakpoints may pas appliquer the façon vous designed les pour mobile.
La plupart modern themes and site builders ajouter ce tag pour vous automatically. But older templates, hand-built pages, and some page builders miss it — qui is pourquoi “viewport pas définir” encore montre up in audits.
The mistake to éviter
Vous pourrait voir a version of ce tag with user-scalable=no on the fin — that’s
someone trying to arrêter visitors from zooming so ils can’t “break” the layout.
Don’t do que. It arrête personnes with low vision from zooming in to lire votre
page, and modern iPhones ignore the setting anyway, so it ne fait pashing except hurt
accessibility. Leave zoom alone.
How ce fits the rest of mobile SEO
The viewport tag is un petit piece of the bigger mobile picture — it’s à propos de how votre page renders on a phone, qui is différent from indexation mobile-first (à propos de qui version of votre page Google reads). Si you’re doing a complet mobile réussir, the mobile SEO hub, the mobile SEO checklist, and indexation mobile-first cover the rest.
Vouloir the exact attribute référence, the accessibility details, and Comment tester the tag now que Google’s old Mobile-Friendly Tester is gone? Switch to the Avancé tab.
Evidence for this claim The viewport meta tag lets authors control viewport width and scaling so responsive layouts render at device width. Scope: Browser viewport behavior. Confidence: high · Verified: MDN: Viewport meta tag Evidence for this claim Pages should not disable browser zoom because users must be able to enlarge content for accessibility. Scope: WCAG resize-text requirement and viewport guidance. Confidence: high · Verified: W3C WAI: Understanding Resize TextTL;DR — The viewport meta tag —
<meta name="viewport" content="width=device-width, initial-scale=1">— hints le navigateur to size the layout viewport to the device’s width in CSS pixels au lieu de a legacy ~980px fallback some mobile navigateurs utiliser, qui is ce que lets responsive CSS media requêtes evaluate contre the device’s réel width on mobile. Manquant or misconfigured, it’s a classic ergonomie mobile échec (tiny text, horizontal scroll). It is pas a ranking factor — Google documents its presence as un chose its mobile-friendliness evaluation checks pour, and aucun plus que que. Jamais forceuser-scalable=no/ restrictivemaximum-scale: it fails the W3C’s ACT accessibility rule pour zoom, though navigateur overrides exist (iOS 10+ ignores it by par défaut). Google and Bing recommend the identical tag. Tester with Lighthouse / PageSpeed Insights — Search Console’s Ergonomie mobile report and the Mobile-Friendly Tester were retired December 1, 2023.
The problem it solves: the ~980px virtual viewport
To comprendre the tag vous have to comprendre ce que it’s overriding. Quand mobile navigateurs were nouveau, the lack of a viewport tag meant some of les voudrait fall back to a fixed layout width of roughly 980px and render at que size — a deliberate accommodation so desktop-sized, pre-responsive sites wouldn’t complètement break on early smartphones. Le navigateur alors scaled le résultat bas to the physical screen. MDN’s propre framing: “Si le site isn’t designed to fonctionner bien on petit viewports and ce tag is omitted, some mobile navigateurs render le site en utilisant a fixed initial containing block width, typically 980px.” — it’s a browser-specific fallback, pas a universal spec constant.
The consequence, in Google’s propre words: “Sans a viewport meta tag, mobile devices render pages at typical desktop screen widths and alors scale lune pages bas, making les difficult to lire.” Vous obtenir unreadable text, forced pinch-zooming, and horizontal scrolling — the textbook symptoms of une page flagged “not mobile-friendly.”
Setting the tag “lets vous contrôler the width and scaling of the viewport so que it’s sized correctement on tout devices.”
Layout viewport vs. visual viewport (sous the hood)
Two “viewports” are in play, and it’s worth keeping les straight:
- The layout viewport is the area lune page lays out into and que fixed-position
elements attach to.
width=device-widthsets ce to the device’s screen width in CSS pixels. - The visual viewport is ce que the utilisateur is currently looking at — qui changements quand ils pinch-zoom. Zooming changements the visual viewport sans modification the layout viewport.
The raison ce matters pour le SEO and CSS: votre responsive media requêtes
(@media (max-width: 600px) and friends) are evaluated contre the layout
viewport. Si the layout viewport is stuck at a legacy ~980px fallback parce que
there’s aucun viewport tag, a phone may match votre desktop breakpoints au lieu de
votre narrow ones. MDN puts it plainly: “Sans it, votre responsive design with
breakpoints and media requêtes may pas fonctionner as intended on mobile navigateurs.” The
tag is ce que rend device-width the layout viewport so votre intended breakpoints
evaluate correctement.
The correct tag, and où it goes
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- ...the rest of your head... -->
</head>Put it élevé in the <head>, near charset, avant content-dependent tags. Ce is
the valeur Google, Bing, and Lighthouse tout recommend — verbatim, it’s the fix
Lighthouse itself suggests. Don’t overthink the valeur: width=device-width, initial-scale=1 is the réponse pour essentially every responsive site.
Attribute référence
The content attribute is a comma-separated liste of directives. MDN is the
canonical attribute-by-attribute référence; here’s ce que chaque un fait:
| Directive | Ce que it fait | Notes |
|---|---|---|
width | Contrôle the (minimum) pixel width of the viewport | A whole number 1–10000, or the special valeur device-width (the screen width in CSS pixels). Utiliser device-width. |
initial-scale | The zoom ratio entre device width and viewport on charger | A number 0.0–10.0. Utiliser 1. |
minimum-scale | The minimum zoom level allowed | Doit be ≤ maximum-scale. iOS 10+ ignores it by par défaut. |
maximum-scale | The maximum zoom-in allowed | Doit be ≥ minimum-scale. iOS 10+ ignores it by par défaut. Don’t restrict it. |
user-scalable | Si the utilisateur peut zoom (yes/no, par défaut yes) | iOS 10+ ignores it by par défaut. Setting no is an accessibility anti-pattern — leave it. |
interactive-widget | How interactive UI (e.g. virtual keyboards) affecter the viewport | Valeurs: resizes-visual (par défaut), resizes-content, overlays-content. Newer; la plupart SEO content omits it. |
viewport-fit | How the viewport handles afficher cutouts (notches) | Valeurs: auto (par défaut), contain (fits à l’intérieur the largest rectangle que avoids the cutout), cover (fills the afficher — pair with CSS env() safe-area-inset variables so content doesn’t land sous the cutout). |
viewport-fit and interactive-widget are les deux browser-layout edge cas —
display-cutout and virtual-keyboard handling, respectively — pas SEO directives;
la plupart SEO-focused guides skip les entirely.
A petit but réel gotcha from Lighthouse’s propre docs: setting initial-scale ci-dessous
1 peut trigger a legacy double-tap-to-zoom behavior que adds interaction delay —
un autre raison to stick with initial-scale=1 plutôt que getting clever.
Jamais disable zoom: user-scalable=no is an anti-pattern
You’ll encore trouver user-scalable=no (or maximum-scale=1) copy-pasted into old
theme boilerplate, usually from a developer who didn’t vouloir pinch-zoom “messing up”
leur layout. It’s incorrect on two counts:
- It fails the web’s propre accessibility conformance tester pour zoom, and it fonctionne
contre WCAG’s intent. The W3C’s ACT rule “Meta viewport allows for zoom”
(rule b4f0c3) s’applique to quelconque viewport tag que sets
user-scalableormaximum-scale, and its expectation is explicit: the tag doit pas définiruser-scalable=no, andmaximum-scaledoit pas be définir ci-dessous2. (The rule carries stated assumptions — it doesn’t appliquer si lune page has aucun visible content, offers un autre façon to resize text, or jamais nécessite to reflow past a 320×256 CSS-pixel area — but a typical responsive page doesn’t meet ceux exceptions.) Per MDN: “Disabling zooming capabilities by settinguser-scalableto a valeur ofnoempêche personnes experiencing low vision conditions from being able to lire and comprendre page content. Additionally, WCAG exige a minimum of 2× scaling; cependant, the meilleur pratique is to enable a 5× zoom.” Blocking zoom locks out the exact utilisateurs who besoin it la plupart. - It’s aussi browser-specific, pas universal. iOS Safari 10 and plus tard ignore
user-scalable=noand restrictivemaximum-scaleby par défaut — that’s an iOS override, pas a modifier to the ACT rule or to WCAG’s intent. So on a grand share of mobile trafic the setting accomplishes nothing, pendant que on navigateurs que do encore honor it (older Android WebViews, some in-app navigateurs) it actively fails the accessibility tester ci-dessus. Zero upside, réel downside — and don’t treat “iOS ignores it” as proof the markup is accessible everywhere.
The rule is simple: don’t touch zoom. width=device-width, initial-scale=1 and
nothing sinon.
Is it a ranking factor?
Be precise ici, parce que a lot of SEO content overstates it. Here’s exactly ce que Google documents, and où the line to industry inference sits.
Ce que Google documents: the viewport tag is pas a direct ranking factor. Google’s propre supported-meta-tags doc dit plainly que “presence of ce tag indicates to Google que lune page is mobile friendly” — that’s the whole documented claim: presence signals mobile-friendliness. Google doesn’t document the tag as scored, as a rendering guarantee, or as proof une page’s responsive design is en réalité bon.
Evidence for this claim Google documents that viewport-meta presence indicates a page is mobile friendly, but that statement does not establish that the tag itself is a ranking factor, a display guarantee or sufficient evidence of responsive quality. Scope: production HTML and HTTP responses Confidence: high · Verified: Meta tags and attributes that Google supportsOù practitioners connecter the dots (industry inference, pas a Google citation): a manquant or misconfigured viewport tag is a courant root causer of the mobile-usability échecs (tiny text, horizontal scroll, unusable tap targets) que SEOs généralement comprendre to degrade mobile page experience. Que connection is reasonable and widely held in the industry, but it’s a practitioner inference à propos de pourquoi the tag matters — pas something Google’s docs state as a ranking chain.
So the honest framing: the tag itself isn’t scored, and fix it parce que une page sans it renders badly on phones — pas parce que Google documents it as a ranking lever, direct or indirect. Garder ce separate from indexation mobile-first aussi: that’s a distinct Recherche Google concept à propos de qui version of votre page Google primarily uses pour indexation and ranking; the viewport tag is à propos de how que mobile HTML renders in a navigateur, complet arrêter.
Evidence for this claim Mobile-first indexing means Google primarily uses the mobile content for indexing and ranking; it is a separate Google Search concept from the browser's viewport rendering contract. Scope: production HTML and HTTP responses Confidence: high · Verified: Mobile-first indexing best practicesComment tester it — the tooling modifié in 2023
Ce is où la plupart older guides are stale. On December 1, 2023, Google retired Search Console’s Ergonomie mobile report, the Mobile-Friendly Tester outil, and the Mobile-Friendly Tester API (announced April 2023, confirmed complet que December). Google’s reasoning was que autre outils had matured — “nombreux autre robust resources pour evaluating ergonomie mobile have emerged, notamment Lighthouse from Chrome.” So si a tutorial indique vous to ouvrir Search Console → Ergonomie mobile to vérifier votre viewport, que report ne … plus exists.
Couche ces checks plutôt que relying on un outil: confirmer the tag exists in the raw served HTML (pas simplement après JavaScript runs), confirmer votre responsive breakpoints en réalité appliquer at phone widths, tester zooming to 200% sans the layout breaking (the resize behavior WCAG’s intent is construit autour), and spot-check in plus que un navigateur — an iOS Safari-only vérifier peut hide a zoom-restriction bug que Android or in-app navigateurs encore enforce.
Votre current toolkit:
- Lighthouse (in Chrome DevTools). The relevant audit historically lire “Fait
pas have a
<meta name="viewport">tag withwidthorinitial-scale” — it fails unless the<head>has ameta name="viewport"whosecontentinclutwidth=. As of Lighthouse 13 it’s folded into the “Optimize viewport for mobile” insight. - PageSpeed Insights — runs Lighthouse plus field Core Web Vitals données.
- Chrome DevTools device toolbar — emulate phone dimensions and eyeball it.
- Bing’s Mobile Friendliness Tester Outil — Bing checks viewport and zoom-control configuration aussi, and recommends the même tag Google fait.
- View source / real-device vérifier — parfois the fastest tester is to simplement regarder
at the
<head>on votre phone.
Erreurs fréquentes
- Aucun tag at tout (“viewport not set”) — lune page renders at the legacy desktop-ish width and shrinks.
- A hardcoded pixel width comme
width=1024au lieu dedevice-width— a tag exists, but it encore doesn’t match lune page to the device. Lighthouse and réel mobile-friendliness les deux vouloir a usablewidth=valeur, pas simplement quelconque tag. initial-scaleci-dessous 1 — peut trigger the legacy double-tap-zoom delay.user-scalable=no/ restrictivemaximum-scale— copy-pasted from old boilerplate; accessibility anti-pattern, ignored on iOS anyway.
Pour où ce sits in the broader mobile fonctionner — configuration, content parity, speed — voir the mobile SEO hub, the mobile SEO checklist, and mobile-first indexation. Pour the tag itself as partie of the wider on-page tag family, the meta tags cluster is the map.
AI summary
A condensed prendre on the Avancé version:
- The viewport meta tag —
<meta name="viewport" content="width=device-width, initial-scale=1">— hints navigateurs to size the layout viewport to the device’s width in CSS pixels au lieu de a legacy ~980px fallback some mobile navigateurs utiliser. It’s ce que lets responsive CSS media requêtes evaluate contre the device’s réel width on mobile. - Sans it: some mobile navigateurs render lune page at que wider fallback and shrink it — tiny text, horizontal scroll, breakpoints que may pas appliquer as intended. Google: “Sans a viewport meta tag, mobile devices render pages at typical desktop screen widths and alors scale lune pages bas.”
- Layout viewport vs. visual viewport:
width=device-widthsets the layout viewport (ce que media requêtes evaluate contre) and acts as a minimum width; pinch-zoom changements the visual viewport seulement. - Attributes:
width,initial-scale,minimum-scale,maximum-scale,user-scalable, and the newerinteractive-widgetandviewport-fit(les deux browser-layout edge cas, pas SEO directives). Utiliserwidth=device-width, initial-scale=1and nothing sinon. - Jamais disable zoom:
user-scalable=no/ amaximum-scaleci-dessous2fails the W3C’s ACT rule pour zoom (b4f0c3) and fonctionne contre WCAG’s resize intent — and iOS 10+ overrides it by par défaut, so it’s an accessibility downside with zero upside anywhere. - Ranking: Google documents seulement que presence “indicates to Google que the page is mobile friendly” — pas que the tag is scored, and pas a stated ranking chain via usability signals (que lien is industry inference, pas a Google citation). Distinct from indexation mobile-first (qui version is indexé, pas how it renders).
- Testing modifié: Search Console’s Ergonomie mobile report, the Mobile-Friendly Tester outil, and its API were retired Dec 1, 2023 — utiliser Lighthouse, PageSpeed Insights, DevTools device toolbar, or Bing’s Mobile Friendliness Tester; couche in a 200%-zoom vérifier and plus que un navigateur.
- Erreurs fréquentes: aucun tag, hardcoded
width=1024,initial-scale< 1, copy-pasteduser-scalable=no. Google and Bing recommend the identical valeur.
Documentation officielle
Primary-source documentation and standards références.
- Meta tags and attributes que Google supports — listes the viewport tag and states its presence “indicates to Google that the page is mobile friendly.” The current, live source (Google’s dedicated older
configure-viewportdoc has been retired). - Ne fait pas have a
<meta name="viewport">tag with width or initial-scale (Lighthouse) — the audit definition, the desktop-width-fallback explanation, and the recommended fix code. - Ce que the Viewport? — Chrome pour Developers / web.dev on the legacy ~980px par défaut and layout vs. visual viewport.
- The role of page experience in creating utile content (Apr 2023) — où Google announced the Dec 1, 2023 retirement of the Ergonomie mobile report and Mobile-Friendly Tester outil/API, pointing to Lighthouse.
Standards / technical référence
<meta name="viewport">(MDN Web Docs) — the principal attribute-by-attribute référence:width,initial-scale,minimum-scale,maximum-scale,user-scalable,interactive-widget,viewport-fit, the iOS 10+ override behavior, and the WCAG accessibility warning.- MDN: Responsive design — the viewport meta tag — the plain statement que breakpoints and media requêtes “may not work as intended” sans the tag.
- MDN: CSS viewport concepts — qualifies the ~980px fallback to “some mobile browsers,” pas a universal par défaut.
- W3C WAI: ACT rule “Meta viewport allows for zoom” (b4f0c3) — the precise accessibility conformance tester:
user-scalable=noandmaximum-scalesous2échouer, with the rule’s propre applicability and assumptions spelled out.
Bing / Microsoft
- Bing’s Mobile Friendliness Tester Outil (in Bing Webmaster Outils) evaluates viewport and zoom-control configuration, content width, text readability, tap-target spacing, and incompatible plug-ins, and recommends the même
width=device-width, initial-scale=1valeur Google fait. (Bing help-doc URLs déplacer periodically; vérifier the current Bing Webmaster Outils aider center pour the live page.)
Quotes from the source
On-the-record statements from Google’s documentation and MDN. Chaque lien jumps to the quoted passage on the source page où a deep lien is disponible.
Google — ce que the tag fait and pourquoi
- “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.” — Lighthouse / Chrome pour Developers (Google). Jump to quote
- “Presence of this tag indicates to Google that the page is mobile friendly.” — Meta tags and attributes que Google supports, Recherche Google Central docs. Lire the doc
MDN — the accessibility warning
- “Disabling zooming capabilities by setting
user-scalableto a value ofnoprevents people experiencing low vision conditions from being able to read and understand page content.” — MDN Web Docs. Lire the référence - On
user-scalable,minimum-scale, andmaximum-scale: “Browser settings can ignore this rule, and iOS10+ ignores it by default.” Lire the référence
W3C — the accessibility conformance tester pour zoom
- Applicability: “This rule applies to each
contentattribute on ametaelement with anameattribute value ofviewportfor which at least one of the following is true: thecontentattribute value has theuser-scalableproperty; or thecontentattribute value has themaximum-scaleproperty.” Expectation: the attribute valeur doit pas définiruser-scalabletono, and doit pas définirmaximum-scaleci-dessous2. — W3C WAI, ACT rule “Meta viewport allows for zoom” (b4f0c3). Lire the rule
MDN — qualifying the legacy fallback and breakpoint behavior
- “If the site isn’t designed to work well on small viewports and this tag is omitted, some mobile browsers render the site using a fixed initial containing block width, typically 980px.” — MDN, CSS viewport concepts. Lire the référence
- “Without it, your responsive design with breakpoints and media queries may not work as intended on mobile browsers.” — MDN, Responsive design guide. Lire the référence
Google — retiring the mobile outils (Dec 2023) (via Moteur de recherche Land’s verbatim coverage)
- “In the nearly ten years since we initially launched this report, many other robust resources for evaluating mobile usability have emerged, including Lighthouse from Chrome.” Lire the coverage
Qui viewport configuration devrait I utiliser?
Pour almost every site the réponse is the même un line — but personnes talk themselves into “clever” variants que causer problems. Click via to land on the correct valeur (and to rule out the anti-patterns).
Choosing your viewport meta tag value
Viewport tag checklist
A rapide réussir to confirmer the tag is présent and sane:
- A
<meta name="viewport">tag exists in the<head>(view source or vérifier votre template/theme head partial). - It’s placed élevé in the
<head>, nearcharset, avant content-dependent tags. - The
contentvaleur iswidth=device-width, initial-scale=1. -
widthisdevice-width— pas a hardcoded pixel number comme1024. -
initial-scaleis1— pas ci-dessous 1 (avoids double-tap-zoom delay). - Aucun
user-scalable=noand aucun restrictivemaximum-scale(zoom stays enabled — accessibility). - Verified with Lighthouse or PageSpeed Insights (pas the retired Mobile-Friendly Tester / Ergonomie mobile report).
- Spot-checked on a réel phone or in the Chrome DevTools device toolbar — text is readable, aucun horizontal scroll.
- Votre responsive CSS breakpoints en réalité appliquer at phone widths (ils may pas sans a correct viewport tag).
- Zoomed to 200% and the layout encore fonctionne sans content getting clipped.
- Spot-checked in plus que un navigateur/engine, pas simplement votre par défaut — an iOS-only vérifier peut hide a zoom restriction que autre navigateurs encore enforce.
Viewport meta tag — cheat sheet
The un line vous vouloir
<meta name="viewport" content="width=device-width, initial-scale=1">Google, Bing, and Lighthouse tout recommend ce exact valeur.
Attribute référence
| Directive | Utiliser | Notes |
|---|---|---|
width | device-width | Or 1–10000 px; utiliser device-width. |
initial-scale | 1 | 0,0–10,0; ci-dessous 1 triggers double-tap-zoom delay. |
minimum-scale | (omit) | iOS 10+ ignores. |
maximum-scale | (omit) | iOS 10+ ignores; don’t restrict zoom. |
user-scalable | (omit; par défaut yes) | no = fails the zoom accessibility rule; iOS 10+ overrides it. |
interactive-widget | (optional) | resizes-visual (par défaut) / resizes-content / overlays-content. |
Symptoms of a manquant/broken tag
- Tiny, unreadable text on mobile.
- Horizontal scrolling / pinch-to-zoom nécessaire.
- Responsive breakpoints pas applying as intended on phones.
- “Viewport not set” in an audit.
Do / Don’t
- ✅
width=device-width, initial-scale=1, élevé in<head>. - ❌ Hardcoded
width=1024. - ❌
initial-scaleci-dessous 1. - ❌
user-scalable=no/maximum-scale=1.
Ranking reality: pas a direct ranking factor. Google documents seulement que its presence indicates mobile-friendliness — the usability→page-experience chain is industry inference, pas a Google-documented ranking mechanism.
Tester with: Lighthouse · PageSpeed Insights · Chrome DevTools device toolbar · Bing Mobile Friendliness Tester. Pas the Mobile-Friendly Tester or Search Console Ergonomie mobile report — les deux retired Dec 1, 2023.
Viewport anti-patterns
The four façons personnes obtenir ce tag incorrect, and Que faire à la place.
1. Disabling zoom (user-scalable=no / maximum-scale=1).
The intent is usually “stop pinch-zoom from breaking my layout.” The reality: it
fails the W3C’s accessibility conformance rule pour zoom and locks low-vision utilisateurs
out of scaling text, and iOS 10+ overrides it by par défaut — so it ne fait pashing on a
huge share of trafic pendant que encore failing que accessibility tester on le navigateurs
que do honor it. Fix: supprimer it entirely; garder seulement width=device-width, initial-scale=1.
2. Hardcoding a pixel width (width=1024).
A viewport tag exists, so audits parfois half-pass, but lune page is encore pinned
to a fixed width que doesn’t match réel devices. Fix: utiliser width=device-width.
3. initial-scale ci-dessous 1 to “fit more on screen.”
Shrinking the initial zoom peut trigger the legacy double-tap-to-zoom behavior que
adds interaction delay, and it rend text plus petit pour everyone. Fix:
initial-scale=1 and let votre responsive CSS handle layout.
4. Relying on the retired GSC Ergonomie mobile report to catch problems. Que report, the Mobile-Friendly Tester outil, and its API were retired December 1, 2023. Si votre QA traiter encore dit “check Mobile Usability,” it’s silently doing nothing. Fix: audit with Lighthouse / PageSpeed Insights à la place.
Bonus — treating the tag as a ranking lever. It’s pas un. Ajout it won’t lift rankings; it simplement rend lune page render correctement so it peut réussir the mobile-friendliness checks que do feed page experience. Définir it une fois, correctement, and déplacer on.
Vérifier and audit votre viewport tag
Façons to vérifier the tag à travers une page or a whole site, from a rapide console snippet to a explorer.
DevTools console — inspect the current page’s viewport tag
// Paste into the Chrome DevTools console on the page you're checking.
const vp = document.querySelector('meta[name="viewport"]');
if (!vp) {
console.warn('❌ No viewport meta tag — "viewport not set".');
} else {
const c = vp.getAttribute('content') || '';
console.log('viewport content:', c);
console.log(/width\s*=\s*device-width/i.test(c) ? '✅ width=device-width' : '⚠️ width is not device-width');
console.log(/user-scalable\s*=\s*no/i.test(c) || /maximum-scale\s*=\s*[01](\.0)?\b/i.test(c)
? '⚠️ zoom is restricted — accessibility anti-pattern' : '✅ zoom not restricted');
}Bookmarklet — one-click vérifier
javascript:(function(){var v=document.querySelector('meta[name=viewport]');alert(v?('viewport: '+v.content):'NO VIEWPORT TAG (viewport not set)');})();Shell — récupérer une URL and grep the raw HTML head
# Prints the viewport tag from a page's server-rendered HTML (or nothing if absent).
curl -s https://example.com | grep -io '<meta[^>]*name=["'\'']*viewport[^>]*>'Shell — flag pages que restrict zoom à travers a liste of URLs
# urls.txt = one URL per line. Prints any page whose viewport disables/limits zoom.
while read -r u; do
html=$(curl -s "$u")
echo "$html" | grep -iq 'name=["'\'']*viewport' || { echo "MISSING $u"; continue; }
echo "$html" | grep -io '<meta[^>]*viewport[^>]*>' | grep -Eiq 'user-scalable=no|maximum-scale=[01]' \
&& echo "ZOOM-OFF $u"
done < urls.txtRegex — match the tag in source (pour a code search / linter rule)
<meta[^>]+name=["']?viewport["']?[^>]*>To flag the anti-pattern specifically, search pour:
viewport[^>]*(user-scalable\s*=\s*no|maximum-scale\s*=\s*[01])Pour a whole-site sweep, a robot d’exploration (Screaming Frog, Ahrefs Site Audit) is faster que scripting — voir the Outils tab.
Outils pour checking the viewport tag
- Lighthouse (Chrome DevTools → Lighthouse, or the CLI) — the direct replacement pour the retired Mobile-Friendly Tester; runs the viewport audit (“Optimize viewport pour mobile” in Lighthouse 13+) plus the rest of ergonomie mobile and performances.
- PageSpeed Insights — Lighthouse in le navigateur, with field Core Web Vitals données alongside the lab audit.
- Chrome DevTools device toolbar — toggle device emulation and eyeball lune page at phone dimensions; the fastest façon to voir a broken viewport.
- Bing Mobile Friendliness Tester Outil (Bing Webmaster Outils) — checks viewport and zoom-control configuration and recommends the même tag.
- Screaming Frog SEO Spider / Ahrefs Site Audit — explorer the whole site and surface pages manquant the viewport tag (or restricting zoom) at scale, au lieu de checking URLs un at a temps.
- View source on votre phone — the lowest-tech vérifier: is the tag en réalité in the
<head>of the served HTML?
Remarque the retirements: Search Console’s Ergonomie mobile report, the Mobile-Friendly Tester outil, and the Mobile-Friendly Tester API were tout retired on December 1, 2023 — don’t reach pour les.
The viewport tag is présent but lune page encore semble desktop-sized
Symptom: source contient a viewport tag, yet phones montrer tiny text or a wide layout.
Probable causer: là are duplicate viewport tags, the tag is injected aussi late, or
the responsive CSS jamais loads. Fix: garder un tag in le serveur-rendered <head>,
supprimer conflicting copies, and vérifier que the attendu media requêtes are applied in
the rendered page.
Mobile layout fonctionne at premier and alors jumps wider
Symptom: the initial layout fits, alors horizontal scrolling apparaît après charger. Probable causer: JavaScript adds a fixed-width widget, table, banner, or iframe après the viewport is established. Fix: inspect the rendered DOM at the moment overflow starts and constrain the injected element. Modification the viewport valeur ne peut pas repair an element que is intrinsically wider que the screen.
Pinch zoom is blocked
Symptom: utilisateurs ne peut pas zoom, même though lune page sinon fits. Probable causer:
user-scalable=no or a restrictive maximum-scale remains in the viewport content.
Fix: supprimer ceux restrictions and retest with navigateur zoom and OS text scaling.
Ne faites pas treat an iOS override as proof que the markup is accessible everywhere.
A robot d’exploration reports the tag manquant but le navigateur montre it
Symptom: a rendered navigateur sees the tag, pendant que a raw-HTML robot d’exploration ne fait pas. Probable causer: client-side JavaScript inserts it. Fix: emit the tag in the initial document head. A foundational rendering instruction ne doit pas depend on a script running successfully.
Validate a viewport-tag modifier
| Tester to run | Attendu result | Échec interpretation | Monitoring window | Rollback trigger |
|---|---|---|---|---|
View the initial HTML réponse and inspect <head> | Exactly un viewport tag contient width=device-width, initial-scale=1 | The tag is manquant, duplicated, or dependent on JavaScript | Every template release | Roll back si a shared template removes or duplicates the tag |
| Charger lune page at several phone widths in DevTools | CSS media requêtes activate at the intended widths and content fits | The viewport is correct but responsive CSS or a fixed-width child is broken | Avant and immédiatement après deployment | Roll back si principal content or navigation becomes unusable |
| Run Lighthouse with a mobile profile | The viewport audit passes | The served or rendered configuration encore empêche a mobile-sized layout | Avant and après the modifier | Roll back si the modifier introduces un autre high-impact mobile échec |
| Tester pinch zoom and increased text size on a physical phone | Utilisateurs peut zoom and text reflows sans clipping | Scaling restrictions or fixed-height components remain | Release day and après design-system changements | Roll back si essential contrôle ne peut pas be reached at enlarged text sizes |
| Explorer a sample from every page template en utilisant raw HTML | Every sample exposes the même valid tag in the head | A template or rendering chemin has inconsistent markup | Après deployment and in scheduled template QA | Roll back the affected template si pages revert to the legacy desktop viewport |
Ressources utiles
My connexe writing
- The Beginner’s Guide to SEO technique — où mobile rendering and page experience fit the bigger technical picture.
- Core Web Vitals: Ce que Ils Are & How to Améliorer Yours — the performances side of the mobile experience que sits suivant to the viewport tag.
My speaking
- How Search Fonctionne (SlideShare) — my walkthrough of exploration, rendering, indexation, and ranking, notamment how Googlebot crawls and renders as a smartphone. (Standing disclaimer: “This is my understanding of systems… not going to be 100% complete or accurate.”)
From autour the industry
<meta name="viewport">(MDN Web Docs) — the precise attribute-by-attribute référence, iOS override behavior, and the WCAG accessibility warning.- Ne fait pas have a
<meta name="viewport">tag with width or initial-scale (Lighthouse) (Chrome pour Developers) — the audit definition, the desktop-width-fallback explanation, and the recommended fix. - Ce que the Viewport? (Chrome pour Developers) — the legacy ~980px par défaut and layout vs. visual viewport, explained by Google.
- Meta tags and attributes que Google supports (Recherche Google Central) — the current doc que noms the viewport tag as a mobile-friendliness signal.
- Google Officially Drops Ergonomie mobile Report, Mobile-Friendly Tester Outil and API (Moteur de recherche Land) — the December 2023 retirements and the Lighthouse recommendation.
- Vous pouvez arrêter en utilisant user-scalable=aucun and maximum-scale=1 in viewport meta tags now (Luke Plant) — background on pourquoi the restrictive zoom attributes existed and pourquoi they’re obsolete and overridden on iOS.
- A Beginner’s Guide to Viewport Meta Tags (Semrush) — a well-rounded competitor explainer covering
interactive-widget, the iOS 10 override, and the WCAG warning.
Testez vos connaissances: Viewport Meta Tag
Five rapide questions on the viewport meta tag. Pick an réponse pour chaque, alors vérifier.
Journal des modifications
Mis à jour le 18 juil. 2026.
Résumé éditorial et détails enregistrés des changements.Détails des changements
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
Comparaison complète indisponible — aucun instantané antérieur n’a été archivé pour cette révision.