Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

What CSS text-box-trim Does—and Why It Can Fix Awkward Text Spacing

CSS text-box-trim can remove space at one or both edges of a text box. Learn how its values work, where they help, and what to check before using them.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

text-box-trim lets CSS trim extra space at the start, end, or both ends of a text box, using boundaries chosen with text-box-edge. It can make headings and controls easier to align, but the right settings depend on the typeface, content, layout, and browsers you need to support. The claim that “nobody’s using it yet” is not established: the available sources do not report an adoption measurement.

What does text-box-trim do?

A line of text occupies space according to its font metrics and line spacing. The visible letters do not necessarily fill that space: a heading or button label can appear to have extra room above or below the glyphs. text-box-trim controls whether CSS trims the text box at its start edge, end edge, both, or neither. text-box-edge specifies the text metric used as the boundary.

As an Amazon Associate I earn from qualifying purchases.

The properties are also available together through the text-box shorthand. This gives designers a way to work with the text box itself rather than compensating for its apparent spacing with arbitrary offsets. The details are defined in the CSS Inline Layout Module Level 3 draft.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do you use it?

For a Latin-script heading or control, this is a reasonable starting point to test:

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
.heading {
  text-box: trim-both cap alphabetic;
}

This requests trimming at both edges, using the capital-letter top at the over edge and the alphabetic baseline at the under edge. The shorthand takes the trim choice followed by the edge values. The MDN text-box reference documents the shorthand and its values.

You can also set the longhands independently:

.heading {
  text-box-trim: trim-both;
  text-box-edge: cap alphabetic;
}

When using the longhands, text-box-trim defaults to none and text-box-edge defaults to auto. The shorthand’s normal value resets to no trimming with automatic edge selection.

Which trim and edge values should you try?

Start by deciding which side needs adjustment, then choose boundaries that suit the typeface and the design. These examples are options to compare, not universal typographic rules:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting What it requests When to test it
trim-start Trim the start (over) edge. When only the space above the text needs adjustment.
trim-end Trim the end (under) edge. When only the space below the text needs adjustment.
trim-both Trim both edges. When both sides need adjustment, such as in a control with text that should sit more evenly within its available space.
cap alphabetic Use the capital-letter top for the over edge and the alphabetic baseline for the under edge. A useful starting point for many Latin-script headings and controls; check it with the actual font and text.
ex alphabetic Use the font’s x-height for the over edge and the alphabetic baseline for the under edge. Compare it with cap alphabetic when the design calls for a different top boundary.

MDN demonstrates comparing trim-end and trim-both with cap alphabetic. Its text-box-trim reference recommends inspecting the result with borders and trying different fonts. Test the real glyphs, font sizes, and content in your design: two settings can produce visibly different results.

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • 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

Where can it help?

Buttons and other controls

Trimming can make the relationship between a control’s text and its padding easier to tune. Chrome for Developers describes using text-box: trim-both cap alphabetic; on a button to remove half-leading and make padding around the label easier to equalize. It does not replace checking the result in the finished control: compare the text with the control’s borders and surrounding elements.

Headings and adjacent elements

For headings, trimming can make the text box’s boundaries easier to coordinate with nearby elements. Check the result with the typeface, size, and actual heading content, rather than assuming that one edge choice will look right everywhere. Chrome’s explanation of the feature and its button example are in Chrome for Developers’ CSS text-box-trim article.

What can prevent trimming from working as expected?

  • Padding or borders: The CSS Inline Layout draft says trimming does not take effect where intervening non-zero padding or borders are present. If a trim appears ineffective, inspect the relevant edge for these values.
  • Formatting context: The draft notes that the property does not apply to, or propagate through, flex, grid, or table formatting contexts. Check the formatting context of the element rather than treating the property as a general-purpose alignment switch.
  • Print output: Print user agents may ignore trimming at an edge if applying it would clip content.
  • Font and text: The result depends on the selected font metrics and the content being rendered. Compare candidate values with the actual font and glyphs, using visible borders while debugging.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Is text-box-trim supported in browsers?

MDN marks text-box and text-box-trim Baseline 2026, newly available across the latest browser versions since August 2026, while cautioning that older browsers and devices may not support them. Chrome for Developers reported that the feature shipped in Chrome 133. These are dated support statements, not a guarantee for every browser version your audience uses; check the current browser support information for your target before relying on it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is “nobody’s using it yet” true?

The available sources do not provide a reliable adoption statistic, so the headline’s claim cannot be treated as a fact. What they do establish is that the feature has documented browser support and a defined use: control the text box’s block-direction edges to make spacing and alignment easier to manage.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.