Feature
CSS text-box trim
The
text-box shorthand property gives authors control over the leading trim applied to a text element's block-start and block-end edges, relative to various font metrics.Why it matters
Every font comes with built-in padding above the cap-height and below the baseline. This half-leading cannot be removed with
margin: 0. Before text-box, designers worked around it with negative margins, padding, or magic-number line-heights — all font-specific hacks.The property
text-box: trim-both removes the half-leading from both ends. Combined with text-box-edge: cap alphabetic you get headings that align precisely to the cap-height, and with text-box-edge: text body text aligns to its actual bounding box.