How to avoid iOS automatic font size adjustment?
CssIosMobile SafariCss Problem Overview
I am NOT talking about zooming the page, but rather the way MobileSafari on iOS automatically bumps up some font sizes sometimes.
When, exactly, is this done? Can it be prevented or discouraged?
Css Solutions
Solution 1 - Css
body {
-webkit-text-size-adjust: 100%;
}
Just make sure all your text is at a legible size in the first place. The iPhone and iPod touch have a rather small screen, so keep that in mind too.
Solution 2 - Css
Had a lot of trouble tracking it down, but: it’s the -webkit-text-size-adjust
property in CSS.
Values:
- Percentage (of default size), e.g.
120%
, or100%
auto
(the default)none
– ifauto
isn’t working for your page. However this often causes problems with zooming. Use100%
instead. For example, open Safari on your desktop and zoom the page (Command-Plus) – your text won’t be enlarged, even though the entire page has zoomed! Don’t usenone
!
Note that these can be applied not just at the page level but at the element/widget/container level.
(I would not just specify a value of 100%
for my website unless I was damn sure it was already optimized for small screens, and never none
since it causes problems.)
Please note that in Firefox Mobile (e.g. for Android and Firefox OS) there is a similar property, -moz-text-size-adjust
, documented here. Thanks to Costa for pointing this out.
Update, 10 years later: This MDN page is probably best for checking what browsers' current compatibilities and vendor prefixes are for this property.
Solution 3 - Css
The accepted answer works, but in other webkit browsers it locks in the font-size
for people that are zooming. Using 100%
instead of none works both ways:
body {
-webkit-text-size-adjust: 100%;
}