Qu'est-ce que Calculateur d'unites CSS root-relative ?
Root-relative font units (Baseline 2026: Chrome 131+, Safari 18.2+, Firefox 136+) give developers access to specific glyph measurements of the root element font. rcap equals the cap height (the height of uppercase letters), rch equals the character width (the advance measure of the 0 glyph), rex equals the x-height (height of lowercase letters like x), and ric equals the ideograph width (typically 1em in CJK fonts). Unlike rem which is simply the root font-size and tells you nothing about the font actual glyph proportions, these units expose the true metrics of the typeface in use.
Réponse rapide
rcap (cap height), rch (character width), rex (x-height), and ric (ideograph width) are root-relative font units that reference specific glyph measurements of the root element font, unlike rem which only reflects font-size. Their pixel values vary by font family. Use rcap for cap-height alignment, rex for vertical rhythm, rch for character-width sizing, and ric for CJK text. Chrome 131+, Safari 18.2+, Firefox 136+ (Baseline 2026).
Limites
- These units reference the root element font, not the element they are applied to. For element-relative glyph measurements, dedicated font-relative units like cap, ch, ex, and ic exist but are also not universally supported. There is no way to reference a specific element own cap height using a unit alone.
- rch measures the width of the zero glyph, which may not represent the average character width for your specific text content. For fields with mixed character widths (like addresses), a width set in rch may overflow for wide characters or leave excess space for narrow ones.
- ric equals 1em in non-CJK fonts, making it redundant with rem for Latin text. The value of ric only differs from rem when the root font includes ideographic glyph metrics, which primarily applies to Chinese, Japanese, and Korean fonts.
Comment utiliser cet outil
- Enter the root font family and size to see the calculated pixel equivalents for rcap, rch, rex, and ric based on the font actual glyph measurements.
- Compare each unit against rem to see the ratio. A font with a large x-height will have a rex value close to rem, while a font with small lowercase letters will have a smaller rex.
- Select a use case from the presets to find the recommended unit -- cap height for alignment, x-height for vertical rhythm, character width for input sizing.
- Copy the generated CSS with the selected unit applied to your chosen property, including a rem fallback declaration.
A quoi il sert
- Align the height of decorative initial caps or drop caps to exactly match the cap height of the surrounding text using rcap, avoiding overshoot or gaps.
- Size form input fields and monospace code blocks based on actual character width (rch) so that a maxlength of 40 fits exactly within the field width.
- Set vertical spacing (margin, padding) on text elements using rex for vertical rhythm that scales proportionally to the font x-height across different typefaces.