Almost every button has the same small problem: the padding is equal above and below, and the label still sits visibly too low. The reason is not the button but the typeface. Every line brings space above the capitals and below the baseline that the font reserves for accents and descenders, and that space is usually larger at the top than at the bottom. Until now the only help was trial and error: one pixel more padding at the bottom, a negative margin, a correction that is wrong again the next time the font changes. text-box cuts that space off, so the box ends exactly at the top of the capitals and at the baseline. Safari was the first browser to ship the property, in version 18.2 in December 2024, Chrome followed with version 133 in early 2025, Firefox with version 154. Since August 2026 MDN lists it as Baseline. This guide shows where the offset comes from, which values exist, where the property helps and where it does not apply.
- Text sits too low in a button because the line brings more empty space above the capitals than below the baseline. Equal padding therefore produces unequal distances to the visible type.
- text-box: trim-both cap alphabetic cuts the first line at cap height at the top and the last line at the baseline at the bottom. After that, the padding equals the distance you see.
- The property applies to block containers and inline boxes and is not inherited. On a button with inline-flex it therefore belongs on the element holding the text, not on the button.
- Browsers without support show the button as before. The declaration is an addition you can add without a query, as long as the padding still looks acceptable untrimmed.
What exactly does text-box-trim do?
It cuts away the space between the edge of the box and the visible type, at the top of the first line, at the bottom of the last one, or both. Where exactly it cuts is set by text-box-edge. With cap the box ends at the top at cap height, with alphabetic at the bottom at the baseline. After that, the padding is the distance you also see.
The text-box shorthand combines both. text-box: trim-both cap alphabetic cuts at cap height at the top and at the baseline at the bottom, and because missing parts are filled in, text-box: cap alphabetic is enough. The initial value is normal, meaning no cut. The property is not inherited and applies to block containers and inline boxes.
Safari shipped it first, in version 18.2, Chrome in version 133. Firefox has supported it since version 154 according to caniuse, and MDN has listed it as Baseline since August 2026. Early drafts called it leading-trim, and older posts still show examples under that name that no longer work today.
.button { padding: 0.75rem 1.25rem; line-height: 1.4;} /* the box now ends at cap height and at the baseline */ .button { text-box: trim-both cap alphabetic; }
Which edges suit which typeface?
For buttons, labels and headings cap alphabetic is almost always the right choice. Most labels start with a capital or consist entirely of them, and the eye measures the space at the top at exactly that edge. At the bottom it measures at the baseline, not at the descenders, which may reach into the padding with a g or a y.
Text set entirely in lowercase is different. There are often no capitals for the eye to orient itself by, and the visible top edge sits at x-height. For that case there is ex as the top edge. A button labelled next or a tag in lowercase then sits in the middle where cap would show it too low.
The third edge, text, matches the font's starting state and is useful where you only want to cut one side. With trim-start or trim-end you can, for example, cut only the top of a heading so it starts flush with an image beside it, while the space to the following paragraph stays the same.
- cap alphabetic For buttons, labels, figures in stats and headings with a capital initial. The most common choice.
- ex alphabetic For labels entirely in lowercase, where x-height is the visible top edge.
- trim-start cap Cut only at the top, for instance so a heading lines up with the top edge of an image or a rule.
What happens in browsers without support?
Nothing that looks broken. A browser that does not know text-box skips the declaration and shows the line as it looked before, with the slight downward offset. So the property adds something on top, it replaces nothing, and an @supports query is not needed for the simple case.
A query is only worth it when the padding is tuned to the cut and would be too large without it. Then you write the padding for the untrimmed version as the default and put the smaller or larger padding together with text-box in an @supports (text-box: cap alphabetic) block. That way every browser gets the height that suits its behaviour.
Two looks are enough to check. In a current browser the space above the capitals has to equal the space below the baseline, easiest to see with a word without descenders like START. In an older browser the button may sit a little lower, but not so tight that the type touches the edge.
.button { padding-block: 0.625rem;} @supports (text-box: cap alphabetic) { .button { padding-block: 0.875rem; text-box: trim-both cap alphabetic; }}
First the version that carries everywhere. Then the cut on top.






