Disable Auto Zoom in Input “Text” tag - Safari on iPhone (ok)

https://stackoverflow.com/questions/2989263/disable-auto-zoom-in-input-text-tag-safari-on-iphone

518

The browser will zoom if the font-size is less than 16px and the default font-size for form elements is 11px (at least in Chrome and Safari).

Additionally, the select element needs to have the focus pseudo-class attached.

input[type="color"],
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="email"],
input[type="month"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="time"],
input[type="url"],
input[type="week"],
select:focus,
textarea {
  font-size: 16px;
}

It's not necessary to use all the above, you can just style the elements you need, eg: just text, number, and textarea:

Alternate solution to have the input elements inherit from a parent style:

sharearrow-up-right improve this answerarrow-up-right follow edited Jan 23 '18 at 12:29arrow-up-rightarrow-up-rightIvararrow-up-right4,2891111 gold badges4242 silver badges4848 bronze badgesanswered Jun 18 '11 at 7:17arrow-up-rightsrikantharrow-up-right5,31711 gold badge1111 silver badges44 bronze badges

show 18 more commentsarrow-up-right458

You can prevent Safari from automatically zooming in on text fields during user input without disabling the user’s ability to pinch zoom. Just add maximum-scale=1 but leave out the user-scale attribute suggested in other answers.

It is a worthwhile option if you have a form in a layer that “floats” around if zoomed, which can cause important UI elements to move off screen.

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">sharearrow-up-right improve this answerarrow-up-right follow edited Sep 28 '18 at 13:15arrow-up-rightanswered Sep 16 '17 at 13:59arrow-up-rightdaxmacrogarrow-up-right4,85911 gold badge1111 silver badges1616 bronze badges

show 10 more commentsarrow-up-right231

New: IOS will still zoom, unless you use 16px on the input without the focus.

I added a background since IOS adds no background on the select.

Last updated

Was this helpful?