CKTIS / CSS
cap — the capital-height unit
The cap unit measures the selected font’s capital height. It lets an element’s dimensions follow typography rather than font-size alone.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
<number>capcap is a font-relative length unit. Normally, 1cap equals the cap-height of the element’s first available font, and 2cap is twice that value. In a font-size declaration, cap is resolved using the parent element’s font metrics. If the element has no parent, it uses the font metrics corresponding to the initial values of the font property.
It is neither font-size nor the exact height of every glyph. When cap-height cannot be determined, the browser uses the font’s ascent. The unit also applies to fonts without Latin letters.
The example creates a square with sides of 1cap. Its pixel size depends on the font, so comparison with H is approximate.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>cap unit</title>
<style>
.sample { font: 48px serif; }
.marker {
display: inline-block;
width: 1cap;
height: 1cap;
background: teal;
vertical-align: baseline;
}
</style>
<div class="sample"><span class="marker"></span> H</div>
</html>Result
A teal square beside H; its width and height are 1cap. The pixel size depends on the selected font.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.