Preserve HTML font-size when iPhone orientation changes from portrait to landscape

DShultz picture DShultz · Apr 26, 2010 · Viewed 96.9k times · Source

I have a mobile web application with an unordered list containing multiple listitems with a hyperlink inside of each li:

...My question is how can I format the hyperlinks so that they DON'T change size when viewed on an iPhone, and the accellerometer switches from portrait -> landscape? Right now, I have the hyperlink font size spec'ed to 14px, but when switching to landscape, it blows way up to like 20px. I want the font-size to stay the same. Here is the code:

Answer

Matt Stevens picture Matt Stevens · Apr 26, 2010

You can disable this behavior through the -webkit-text-size-adjust CSS property:

html {
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape while allowing user zoom */
}

The use of this property is described further in the Safari Web Content Guide.