Sheath rule
a11y-no-non-scalable-viewport
Viewport must allow user scaling for accessibility.
- Package
- Core
- Category
- Accessibility
- Default severity
- error by default
- Auto-fix
- Auto-fix available
(dangerous)
#Why
Preventing users from zooming on mobile devices is an accessibility issue. Users with low vision may need to zoom in to read content. The following values restrict scaling and are reported:
user-scalable=no- unknown
user-scalablevalues, which viewport processing converts to a fixed scale - a numeric
maximum-scalebelow2 maximum-scale=yes, which viewport processing translates to1maximum-scale=noand unknown values, which viewport processing translates to0.1
These settings violate WCAG 2.2 Success Criterion 1.4.4 (Resize Text).
The fixer removes the restrictive viewport settings. This is dangerous and
requires --dangerous, because it changes the user's zoom interaction.
#Examples
#Bad
<!-- Disabling user scaling -->
<meta name="viewport" content="width=device-width, user-scalable=no">
<!-- user-scalable=0 also disables scaling -->
<meta name="viewport" content="width=device-width, user-scalable=0">
<!-- Maximum scale of 1 prevents zooming -->
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<!-- Maximum scale below 2 prevents the required 200% zoom -->
<meta name="viewport" content="width=device-width, maximum-scale=1.5">
<!-- The special yes value translates to a maximum scale of 1 -->
<meta name="viewport" content="width=device-width, maximum-scale=yes">
<!-- Combination that prevents zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
#Good
<!-- Allow user scaling (default) -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Explicitly allowing scaling -->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
<!-- Allow zooming up to 5x -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
<!-- No maximum-scale restriction -->
<meta name="viewport" content="width=device-width">
#Notes
- The default browser behavior allows zooming - don't override it
- If your design "breaks" when zoomed, fix the design rather than preventing zoom
- Use relative units (em, rem, %) for better responsive scaling
- Test your site at 200% and 400% zoom levels
- A static
maximum-scaleuses the browser's leading-number parsing. Values such as1.5footherefore still impose a scale below2and are reported;device-widthanddevice-heighttranslate to10, negative values are dropped, and other non-numeric values translate to0.1. Dynamic values are left alone - Viewport properties may be separated by HTML whitespace as well as commas or semicolons. Repeated properties use the last declaration, matching CSS descriptor cascading; a dangerous fix removes every earlier occurrence that could otherwise become effective
#References
- WCAG 1.4.4 Resize Text - Level AA success criterion requiring text resizing up to 200%
- ACT: Meta viewport allows for zoom -
maximum-scalemust not be less than 2 - MDN: Viewport meta tag - Documentation on viewport configuration options
#Related Rules
- best-practices-require-meta-viewport - Require viewport meta tag