Categories: css-tricks.com

Your CSS reset needs text-size-adjust (probably)

Kilian Valkhof:

[…] Mobile Safari increases the default font-size when you switch a website from portrait to landscape. On phones that is, it doesn’t do it on iPad. Safari has been doing this for a long time, as a way to improve readability on non-mobile optimized websites. While undoubtedly useful in a time when literally no website was optimized for mobile, it’s significantly less helpful nowadays. […] Text size increasing randomly in a single situation is exactly the type of thing you want to guard for with a CSS reset.

This is very literally what text-size-adjust does. MDN:

When an element containing text uses 100% of the screen’s width, the algorithm increases its text size, but without modifying the layout. The text-size-adjust property allows web authors to disable or modify this behavior, as web pages designed with small screens in mind do not need it.

You can see Apple’s own docs showing off this is exactly what they do (on iPhones). There is an ancient bug where this would prevent zooming, but probably not a huge concern anymore.

Kilian’s recommendation:

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

Firefox doesn’t even support it, so I’d maybe lose that vendor prefix, but otherwise I’d say I’m on board. I’d like to think I can handle my own text sizing.

Reminds me of how Mobile Safari does that zooming thing with text inputs under 16px, so watch out for that too.

To Shared LinkPermalink on CSS-Tricks


Your CSS reset needs text-size-adjust (probably) originally published on CSS-Tricks. You should get the newsletter and become a supporter.

hnikoloski

Share
Published by
hnikoloski

Recent Posts

Quick Hit #21

Seeing a lot more headlines decrying JavaScript and pumping up PHP. Always interesting to see…

3 hours ago

CSSWG Minutes Telecon (2024-09-18)

For the past two months, all my livelihood has gone towards reading, researching, understanding, writing,…

4 hours ago

Quick Hit #20

Having fun with Bramus’ new Caniuse CLI tool. This’ll save lots of trips to the…

1 day ago

Quick Hit #19

Two possible syntaxes for CSS masonry, one draft specification, and you get to share your…

1 day ago

Re-Working the CSS Almanac

Getting right to it: the CSS-Tricks Almanac got a big refresh this week! I’m guessing…

1 day ago

Clever Polypane Debugging Features I’m Loving

I’m working on a refresh of my personal website, what I’m calling the HD remaster.…

3 days ago