Fonts
font-size-adjust
font-size-adjust adjusts the font size so that text looks about the same size even when the font changes, by matching a measure such as the height of lowercase letters. It keeps text from suddenly looking smaller when a fallback font is shown.
Syntax
none | [ ex-height | cap-height | ch-width | ic-width | ic-height ]? [ from-font | <number [0,∞]> ]Preview
Presets
Drag the bottom-right corner to resize
Code
.box {
font-size-adjust: 0.5;
}Controls
font-size-adjust0.5
Ratio
Metric to match
About
Writing the value
none: the initial value. No adjustment. Even with the samefont-size, lowercase letters look taller or shorter depending on the font.- A number such as
0.5: changes the size of each font so that the measure to match (by default, the height of a lowercase x) is that share of thefont-size. With 0.5 andfont-size: 64px, the x is 32px tall. from-font: uses the ratio of that measure in the first available font instead of a number. The first font keeps its size, and the other fonts match its measure.
You can write the measure to match before the number or from-font. When left out, it is ex-height.
ex-height: the height of a lowercase xcap-height: the height of capital lettersch-width: the width of the digit "0"ic-widthandic-height: the width and height of the CJK character "水". Use them to match the size of full-width characters such as Japanese.
The preview shows "Ax" in the box's font (sans-serif) next to "Ax" in a serif font such as Times New Roman. With none the serif x is shorter even at the same font-size, and with 0.5 both x's line up at the same height.
When to use it
Use it to bring the apparent size of a fallback font, shown when the chosen font is missing or while a web font is loading, closer to the chosen font.
Watch out
- It is inherited, so setting it on the box affects all the text inside. With a number, the first font changes size too and no longer matches the
font-sizeyou wrote. Usefrom-fontto keep the first font as it is. - While a web font has not loaded yet, a fallback font is the "first available font", so
from-fontuses that font's ratio. - Every form you can pick here works from Chrome and Edge 127, Firefox 118, and Safari 17.