Skip to content

Commit 70c8571

Browse files
committed
Add note about some text rendering large on mobile
1 parent 37c59b4 commit 70c8571

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed
38.5 KB
Loading
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: "What Do: Mobile Browsers Render Some Text Larger"
3+
dateCreated: 2025-12-26
4+
dateUpdated: 2025-12-26
5+
---
6+
7+
import Picture from "@/components/picture.astro";
8+
9+
import largeTextOnMobileJpg from "@/assets/large-text-on-mobile.jpg";
10+
11+
Given the following situation on mobile where certain text are rendered larger
12+
than the font size you've set:
13+
14+
<Picture
15+
alt="One code block being rendered with significantly larger text compared to another code block."
16+
{...largeTextOnMobileJpg}
17+
/>
18+
19+
What do if you want consistent font size rendering on all platforms?
20+
21+
Disable any text inflation algorithms being applied by browsers:
22+
23+
```css
24+
html {
25+
-webkit-text-size-adjust: none;
26+
text-size-adjust: none;
27+
}
28+
```
29+
30+
**Note:** Some ancient WebKit-based browsers, specifically Chrome 27 and Safari
31+
6 or older, had a bug where they prevented zooming in and out if
32+
`-webkit-text-size-adjust` is set to `none`. Realistically, practically nobody
33+
uses these browsers anymore, but if you want to cover all of your bases, setting
34+
`-webkit-text-size-adjust` to `100%` instead of `none` has the same effect.
35+
36+
## Additional Information
37+
38+
Since web browsing was initially a desktop only thing mobile browsers
39+
implemented ways to make websites designed for desktops to work on mobile. This
40+
included enlarging certain text using text inflation algorithms.
41+
42+
In my specific case, this text enlargement was going awry on this website's code
43+
blocks when they reached a certain horizontal length. Interestingly, it only
44+
happened on iOS Safari and not on Android Chrome. This leads me to believe that
45+
this might be a bug in Safari. Particularly, because this website sets the
46+
`content` of `<meta name="viewport">` to
47+
`width=device-width, initial-scale=1.0`, which should tell browsers that they
48+
don't need to do any weird text scaling since this website is already built with
49+
different device sizes in mind. I couldn't pinpoint exactly what conditions are
50+
needed to manifest this, but during my testing, it seems it has to do with the
51+
following structure where a parent set to `display` `inline-block` has a child
52+
set to `position` `relative` that's displaying monospace text of a certain size
53+
and length:
54+
55+
```html
56+
<pre style="display: inline-block">
57+
<code style="position: relative">Some long text here...</code>
58+
</pre>
59+
```
60+
61+
I'm not sure how accurate this is, but for now, that's as far as I got and am
62+
willing to go to investigate it.
63+
64+
## References
65+
66+
- https://stackoverflow.com/q/3226001
67+
- https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/text-size-adjust
68+
- https://caniuse.com/text-size-adjust
69+
- https://bugs.webkit.org/show_bug.cgi?id=56543

src/styles/article.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ article {
99
p,
1010
ul,
1111
pre,
12-
a:has(picture) {
12+
picture {
1313
margin-bottom: v-size(6, "em");
1414
}
1515

0 commit comments

Comments
 (0)