How can double-tap zoom be disabled on Safari mobile?
There are some rules for default behaviour: With text it somehow depends on font-size. Other types of elements also allow to be double tapped and usually perform a zoom then (e. g. img).
But the entire double-tap zoom should be disabled.
These were common approaches:
- Applying
touch-action: manipulation
to*
; does not work at all. - Applying
touch-action: none
to*
; seems to disable zooming back out from the zoomed-in position… <meta name="viewport" ...>
; the browser ignores it.- Then, there were some JavaScript/jQuery solutions but none seemed to work at all or work reliably.
Here is an example that does not zoom on double tap (even small text): https://www.amazon.de/dp/B0D5MF64XM
Here is an example that does zoom on double tap: https://dr-adler.com
(Sorry for the URLs; embedding interactive code examples here does not reliably demonstrate the problem…)
2
Answers
Safari Mobile lacks a straightforward way to universally disable double-tap zoom. Typical approaches like touch-action: manipulation or user-scalable=no in the viewport meta tag often don’t work reliably on Safari Mobile. Here’s a JavaScript workaround to prevent double-tap zoom:
This script stops double-tap zoom by treating consecutive taps within 500ms as invalid. Adjust the timing if necessary. This solution doesn’t disable pinch-to-zoom, preserving accessibility.
Try this: add user-scalable=no in your viewport meta tag, then use JavaScript to prevent double-tap zoom by tracking touchend events like this:
This combo blocks double-tap zoom on Safari without affecting pinch-to-zoom.