Last active
January 28, 2026 14:23
-
-
Save colingourlay/d95908ec5cd4854c7a5afa06f3989479 to your computer and use it in GitHub Desktop.
Support Apple's dynamic text sizing in web content (iOS Safari & WebViews)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| To support dynamic type in iOS, we need to set Apple's | |
| system font and then define font-families and rem-based | |
| font-sizes on descendant elements: | |
| */ | |
| @supports (font: -apple-system-body) { | |
| html { | |
| font: -apple-system-body; | |
| } | |
| } | |
| body { | |
| font-family: <your_font_family_here>; | |
| } | |
| p { | |
| font-size: 1.25rem; | |
| } | |
| /* | |
| If you've set a custom rem size in px on the html | |
| element, and want to maintain that on non-Apple | |
| devices, the font override muse be !important: | |
| */ | |
| body { | |
| font-size: 20px; | |
| } | |
| @supports (font: -apple-system-body) { | |
| html { | |
| font: -apple-system-body !important; | |
| } | |
| } |
Author
@tedw thanks for sharing your experience. I'm looking forward to the new meta option!
@colingourlay no prob, thanks for creating this gist!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case anyone else stumbles on this, here’s how I adapted the example above.
I had to use JS to detect the iOS user agent string since this was causing issues on desktop Safari.
FYI a new tag is in the works to support this
<meta name="text-scale" content="scale" />https://www.joshtumath.uk/posts/2026-01-27-try-text-scaling-support-in-chrome-canary/