Search

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;
}Code language: CSS (css)

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.

Wanna be a better web typographer?

Frontend Masters logo

It was once famously said that the web is 95% typography. You can't be a web designer and ignore type! We have an in-depth course on web typography from Jason Pamental getting into things like responsive styles, variable fonts, font loading, and more.

One response to “Letting iOS “Text Size” Setting Affect Font Size on the Web”

  1. Avatar Steve says:

    I tried this on my own site when Craig posted about it originally. The problem I found is that this also applies on macOS, and I’m not sure setting the “Text Size” in Settings has any effect. The default is 13px, which is far too small for desktops, I think anyway.

Leave a Reply

Your email address will not be published. Required fields are marked *

Frontend Masters ❤️ Open Source

Did you know? Frontend Masters Donates to open source projects. $313,806 contributed to date.