Letting iOS âText Sizeâ Setting Affect Font Size on the Web
Letting iOS âText Sizeâ Setting Affect Font Size on the Web êŽë š
On iOS, there is a setting for Text Size. Iâll do a video here for the current version of iOS (17.5.1) to be clear:
As far as I ever knew, that controlled the text size on the OS itself and native apps. It didnât effect websites. I think thatâs largely true, but I just learned you can honor the setting on the web as well. Craig Hockenberry wrote about this in Dynamic Type on the Web:
This is a big win for accessibility: many folks make this adjustment on their device to match their abilities. Just because you can read a tiny font doesnât mean that I can. It also is a win for consistency: my siteâs font size matches the other text that a visitor sees on their device.
I tend to agree. While I think few sites will actually do this, itâs nice when they do. Itâs a little similar to using font family keywords like system-ui
which, when supported, will match the operating systemâs font, only this is even better as itâs an accessibility thing not just aesthetic.
Hereâs the the trick:
html {
/* Default, relative sizing so other users can adjust in their own way */
font-size: 1em;
/* If supported, inherits the iOS font settings */
font: -apple-system-body;
/* Override the font-family if you don't want system-ui */
font-family: "Avenir Next", "Helvetica Neue", sans-serif;
}
Hereâs an example page.
And hereâs a video showing it working:
I havenât actually done it yet on a production project, so I canât entirely vouch for it, but it seems safe to me and like a good idea. Iâll likely give it a go in the future.