Reputation: 16598
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?
Upvotes: 56
Views: 61543
Reputation: 16598
Had a lot of trouble tracking it down, but: it’s the -webkit-text-size-adjust
property in CSS.
Values:
120%
, or 100%
auto
(the default)none
– if auto
isn’t working for your page. However this often causes problems with zooming. Use 100%
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 use none
!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.
Upvotes: 33
Reputation: 1936
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%;
}
Upvotes: 15
Reputation: 724452
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.
Upvotes: 85