← Chrome 149 reference

v149 · css · shipped

CSS text-box

Trim the invisible leading space above the cap height and below the alphabetic baseline that line-height adds to every text block. The text-box shorthand (or its longhands text-box-trim / text-box-edge) removes those gaps, making precise text-to-element alignment a pure-CSS problem.

at a glance

Shipped inChrome 149 (desktop + Android)
StatusEnabled by default
FlagNone
SpecCSS Inline Layout Level 3 §text-box
ChromeStatuschromestatus.com/feature/5174589850648576

why it exists

Every line of text in CSS inherits half-leading above and below from its computed line-height. That invisible space is great for multi-line prose but a nuisance when you want a heading to sit flush against a coloured box, or an icon to align optically with adjacent text. Before text-box, designers faked the trim with negative margins or magic numbers that broke on font changes. text-box instructs the browser to clip the block-start and/or block-end edge of a text container exactly at the defined text metric.

Source: CSS Inline Layout Level 3 §propdef-text-box-trim.

the properties

text-box (shorthand)

Propertytext-box
Syntaxnormal | <text-box-trim> || <text-box-edge>
Applies toBlock containers, multi-column containers, inline boxes
InheritedNo (text-box-edge is separately inherited)
Initialnormal
NotesWhen shorthand omits text-box-trim, it defaults to trim-both. normal resets both longhands.

text-box-trim

ValueEffect
noneNo trimming. Default; existing behaviour.
trim-startTrim the block-start side of the first line (removes leading above).
trim-endTrim the block-end side of the last line (removes leading below).
trim-bothBoth trim-start and trim-end.

text-box-edge

ValueEffect
autoUses the line-fit-edge value; "leading" is treated as "text".
textTrim to the text-over/text-under baselines.
capTrim block-start to the cap-height baseline (top of uppercase letters).
exTrim block-start to the x-height baseline.
alphabeticTrim block-end to the alphabetic baseline (bottom of most lowercase letters).
ideographicTrim to ideographic-over/under baselines (for CJK).
ideographic-inkTrim to ideographic-ink-over/under baselines.

The most common pair is cap alphabetic: trim above to cap height, below to the alphabetic baseline. This is the "tight Latin text" preset.

Source: CSS Inline Layout Level 3 §propdef-text-box-edge.

example: heading flush inside a coloured box

h1 {
  /* Without text-box, the padding visually looks uneven because
     of half-leading above and below the text. */
  padding: 1rem;
  background: oklch(90% 0.15 260);

  /* With text-box: leading is removed; padding is optically even. */
  text-box: trim-both cap alphabetic;
}

example: icon + text optical alignment

.label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.label span {
  font-size: 1rem;
  line-height: 1.5;
  /* Remove the invisible leading so the text baseline aligns
     with the icon's visual centre, not the line box centre. */
  text-box: trim-both cap alphabetic;
}

browser support

Chrome149+
Edge149+ (tracking Chromium)
FirefoxNo signal yet
SafariNo signal yet
Source: chromestatus.com/feature/5174589850648576, May 2026.

see also