Accepting selected projects for Q2 2024 Check availability →
SERVER 02SYSTEM ONLINELAST SYNC: 03:17:44RSS 2.0 — ONLINE
HALF ASSEDTECHNICAL NOTES_
EST. 1999ISSUE 04.2BEST VIEWED AT 1024 × 768
TECHNICAL NOTES / TECHNICAL NOTES / MOBILE / RECORD 60e8ca
[MOBILE]NOTE

Notes on the viewport meta element

POSTED: 16.11.2010AUTHOR: ADMIN5 MIN READCOMMENTS: 0

Handheld WebKit browsers lay out a page on a wide virtual viewport, 980 pixels in Mobile Safari, and scale the result to fit the screen. The viewport meta element tells the browser that the page has been designed for the device width instead.

Declare the device width

Set width=device-width on pages whose layout has actually been prepared for a narrow screen. Applying it to a fixed 960-pixel design produces a page that opens zoomed into the top-left corner and is harder to use than the default behaviour.

Leave zooming available

Avoid user-scalable=no and maximum-scale=1 as general settings. They are frequently added to stop the page enlarging when an iPhone is rotated, but they also prevent users with reduced vision from enlarging text. Accept the rotation behaviour as the smaller defect.

Test beyond one handset

Android devices vary in pixel density and in how they interpret the element, and other mobile browsers may ignore it. Check portrait and landscape orientation on physical devices; a narrowed desktop browser window does not reproduce viewport scaling.

MARKUP ONLY

The element changes the width at which the layout is calculated. It does not make a page suitable for a handheld device; the stylesheet must still do that.