rex
How tall a lowercase x is in the font set on the root element.
Use with a fallbackBaseline: newly available since January 2026
| Browser | Since |
|---|---|
| Chrome | 111+ |
| Chrome Android | 111+ |
| Edge | 111+ |
| Firefox | 147+ |
| Firefox Android | 147+ |
| Safari | 17.2+ |
| Safari iOS | 17.2+ |
Formula 1rex = the value of ex on the root element
How it works
1rex takes the x-height from the root element’s font instead of the font of the element it is written on. A card set in a serif and a toolbar set in a sans-serif get icons of the same height with 1.2rex, where ex would give two sizes. It does for the x-height what rch does for the width of a zero.
Unlike rem, which depends only on the root’s size, rex depends on the root’s font family as well. Changing font-family on html changes every rex on the page, even when the size stays put.
Reach for rex when a rhythm of small details should be uniform across the page and not follow whichever font a component chose. For marks that should follow the neighboring text, use ex.
Try it
Measure the font-relative units
Pick a font and a size. The page measures 1em, 1ex, 1ch, 1cap and 1lh in that font, here, in your browser.
| Unit | Measured | Share of the font size |
|---|---|---|
1em | ||
1ex | ||
1ch | ||
1cap | ||
1lh |
The same as a table
| Unit | Measures |
|---|---|
1em | The font size of the element. |
1ex | How tall the letter x is in this font. |
1ch | The width of the digit zero in the font. |
1cap | The height of a capital letter in the font. |
1lh | The line height of the element. |
What changes it
- Moves with
- the reader's text size
- page zoom
- the font in use
- Stays put under
- the window size
- the query container
- phone toolbars
- the writing mode
Reach for it when
Small marks that must share one height across components set in different fonts.
Watch out
Where the unit is unknown the browser throws the declaration away. Write a rem value first and the rex line after it, so older browsers keep the first one.
.icon {
block-size: 1rem;
block-size: 2rex;
}