Viewport meta and visual viewport
visualViewport reports pinch-zoom scale and on-screen keyboard offsets.
In one line
Can see your pinch zoom level and when the on screen keyboard pops up
visualViewport reports pinch-zoom scale and on-screen keyboard offsets.
Scale above 1 tells the person is zoomed in (accessibility); height shrink exposes the on-screen keyboard. Updates live as the user pinches or types.
What it can and can't do
What the user does: You pinch to zoom, or tap a box that opens the keyboard.
It can
- Check your current pinch zoom scale
- See changes to the visible area, such as when the keyboard opens
- Move buttons so they stay above the keyboard
It cannot
- See what you type on the keyboard
- Tell which keyboard app you use
- Zoom the page for you
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 61 | 2017-09-05 | None |
| Edge | Supported | 79 | 2020-01-15 | None |
| Firefox | Supported | 91 | 2021-08-10 | None |
| Safari | Supported | 13 | 2019-09-19 | None |
| Safari on iPhone | Supported | 13 | 2019-09-19 | None |
| Chrome on Android | Supported | 61 | 2017-09-05 | None |
| Samsung Internet | Supported | 8.0 | 2018-07-18 | None |
How a site asks for it
| API | window.visualViewport.scale, width, height, offsetTop, 'resize' event |
| Browser compat keys | api.VisualViewport |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| How long it lasts | read fresh on every page load; nothing stored |
| How to take it back | none needed (no grant) |
| Inside an iframe | Readable from cross-origin iframes too (same values) |
Typical flow
- Page script reads the value
- No prompt is shown
Data you get
Shape: object
How often: static per session
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
scale | float | ratio | 0.25 to 5 | 0.01 |
width, height | float | CSS px | Not listed | sub-pixel |
Technical limits
- Browser pinch scale differs per OS
The story
What it is
Reports pinch zoom level and how far the on screen keyboard has pushed the page.
For you
You never see the reading. It is why a chat box slides up neatly above the keyboard when you start typing on your phone.
For makers
Makers use it to keep inputs visible and to adapt to zoom. The same numbers can show how a person holds and uses a device, which fraud teams can use.
Where you see it
| Type | Example | Apps |
|---|---|---|
| messaging | A chat site lifts the message box above the on screen keyboard so you can see what you type. | WhatsApp Web, Slack |
| games | A browser game keeps its controls on screen when the keyboard opens for chat. | None named |
| maps | A web map redraws labels when you pinch to zoom. | Google Maps |
| shopping | A checkout form scrolls the card number field into view when the keyboard pops up. | None named |
| security | A bot check sees a browser that never pinch zooms or shows a keyboard on a supposed phone. | None named |
| accessibility | A site keeps text readable when a user zooms in a lot. | None named |
| creative | A drawing app tells drawing taps apart from zoom gestures. | None named |
Risks
- Behavior fingerprint
- Reveals zoom use
What the platform says
- MDN: Visual Viewport API. Explains how a page can read the part of the page currently visible, including zoom and keyboard changes.
Good uses and abuse
Legitimate uses
- Keyboard-aware UI
Known abuse
- Zoom behavior
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 3 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 1 | Rough identifying entropy, when known |
Sources
How well checked: Based on official documentation.