Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Support Apple's dynamic text sizing in web content (iOS Safari & WebViews)
/*
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment