For an English headline that should begin at the top of its capital letters and end at the alphabetic baseline, try text-box: trim-both cap alphabetic;. This trims the text box to chosen font metrics instead of using negative margins to compensate for extra space around the text.
Why headline text boxes can look too tall
The visible gap around text is not always caused by margins. Font metrics and line-height also affect the size of a text element’s line box, and different fonts can produce different line-box heights at the same font size. Negative margins can nudge a headline into place, but they do not directly define where its text box should begin or end.
As an Amazon Associate I earn from qualifying purchases.
CSS text-box trimming gives you a direct way to trim the block-start edge, block-end edge, or both to selected font metrics. It addresses text-box spacing; it is not a general fix for unrelated margin, padding, or layout problems.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWhat `text-box-trim` and `text-box-edge` control
text-box-trim selects which edge to trim. text-box-edge selects the font metric used as the boundary. The text-box shorthand combines both settings.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
| Setting | Effect |
|---|---|
text-box-trim: none |
Default; trims neither edge. |
text-box-trim: trim-start |
Trims the block-start edge only. |
text-box-trim: trim-end |
Trims the block-end edge only. |
text-box-trim: trim-both |
Trims both edges. |
text-box-edge: cap alphabetic |
Uses the top of capital letters as the start boundary and the alphabetic baseline as the end boundary. |
text-box-edge: ex alphabetic |
Uses the top of the lowercase x-height as the start boundary and the alphabetic baseline as the end boundary. |
Choose a trim that matches the design
Start with capital tops and the alphabetic baseline
For an English headline intended to start at the tops of capital letters and finish at the alphabetic baseline, use:
h1 {
text-box: trim-both cap alphabetic;
}
This is a practical starting point, not a universal setting. Check the result with the actual typeface and headline text; the font’s metrics affect where the chosen boundaries fall. For more detail on the shorthand and edge values, see MDN’s `text-box` reference and `text-box-edge` reference.
Rank #2
Trim only the edge that needs correction
If the excess space is only above or below a heading, use trim-start or trim-end rather than trimming both automatically. Which edge and metric to choose depends on the intended optical boundary, typeface, and whether the heading wraps. The available documentation describes the controls, not comparative performance testing.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Preserve intentional breathing room
Leading can provide deliberate visual space around text. Trimming may make a heading, button label, or paragraph feel too tight, so compare the result in the real design rather than applying one rule to every text element. Chrome for Developers discusses text-box trimming as a way to control spacing and alignment in these cases: CSS text-box trimming.
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Check browser and script support
MDN marks the property Baseline 2026 and says it has worked across the latest devices and browser versions since August 2026. Can I Use lists support in current Chrome, Edge, Safari, and Firefox releases in its 2026 table; earlier releases remain unsupported, and support for some other browsers is unknown or absent. Check the versions your audience uses before relying on trimming as the only spacing rule. Can I Use estimates support at 86.46% using its August 2026 StatCounter usage-share period; that is a dated estimate, not a guarantee for every audience. See Can I Use’s compatibility table.
There is also a standards caveat for scripts whose relevant font metrics may be missing. The CSSWG editor’s draft, dated August 11, 2026 and explicitly marked work in progress, gives Hebrew as an example. Test the actual scripts and fonts in your design rather than assuming an English-oriented metric behaves consistently across writing systems: CSS Inline Layout Module Level 3 editor’s draft.
Quick Recap
Best Value
Rank #4
Test the rule in the context where it will be used
- Check the selected boundary against the actual typeface and text, including headings that wrap.
- Compare both-edge trimming with a single-edge trim if only one side looks wrong.
- Review headings, buttons, and paragraphs separately if they rely on intentional leading.
- Check browser versions and the scripts your audience uses before removing existing spacing fallbacks.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools




