Stop Faking Trimmed Underlines: text-decoration-inset Has Landed
October 7, 2026 | 7 min read | CSS
By Syed · Frontend Engineer & Creator of UITweak
You style a nav CTA with a thick custom underline (text-decoration: underline 3px) and the line runs past the last letter on both sides. It looks sloppy, so you reach for the old hack: a background: linear-gradient(...) sized to the text, animated with background-size on hover. It works until the text wraps, the font loads late, or someone zooms, then the magic numbers fall apart. Chrome 154 (September 2026) shipped the native fix: text-decoration-inset controls exactly where the decoration starts and ends.
30-second version: text-decoration-inset: 0.2em shortens the underline by 0.2em on both ends; two values set start and end separately; negative values extend past the text; auto keeps adjacent underlines from merging. It is new (Chrome 154+), so gate it with @supports.
Recipe 1: Trim the Overshoot
The core fix. Positive values inset the decoration: pull it in from the text edges:
.cta-link {
text-decoration: underline 3px solid currentColor;
text-underline-offset: 6px;
text-decoration-inset: 0.25em; /* trim both ends */
}The underline now starts and ends a quarter-em inside the text instead of bleeding past it. Use em units so the trim scales with the font size. the same rule works on a 14px nav link and a 48px display headline.
Recipe 2: Asymmetric Trim (and Outset)
Two values set the start and end independently, and negative values extend the decoration past the text instead of trimming it:
/* hang the end short, keep the start flush */
.headline-accent {
text-decoration: underline 4px solid oklch(0.65 0.2 250);
text-decoration-inset: 0 0.6em;
}
/* marker-highlight look: overshoot on purpose */
.marker {
text-decoration: underline 0.9em oklch(0.85 0.15 95);
text-decoration-skip-ink: none;
text-decoration-inset: -0.1em; /* bleed past both edges */
}The marker example is the old highlighter effect done natively: a thick underline sitting behind the text (painted under it like a highlight), extended slightly past both edges. Previously this needed a wrapper span or a background gradient; now it is two declarations.
Recipe 3: The Native Underline Reveal
Animate the inset and the underline draws itself in. no pseudo-elements, no background-size tricks. Going from 50% on both ends to 0 reveals the line from the center outward:
.reveal-link {
text-decoration: underline 2px solid currentColor;
text-underline-offset: 4px;
text-decoration-inset: 50%; /* fully trimmed = invisible */
transition: text-decoration-inset 0.35s ease;
}
.reveal-link:hover {
text-decoration-inset: 0; /* full width */
}One gotcha: animate length to length, not auto to a length. The auto keyword computes to a browser-chosen value, and interpolating from it is unreliable across engines. Start your reveal from an explicit 50% or 0.5em and it transitions cleanly.
Try it now: design the reveal motion itself in our free CSS Animation Generator: pick the easing curve and duration, preview it live, then drop those values into the transition on text-decoration-inset from Recipe 3. You get a hand-tuned draw-in effect with zero extra elements.
The auto Value: Stop Merged Underlines
When two underlined runs sit side by side (two linked author names, adjacent tags), their decorations merge into what looks like one continuous line. text-decoration-inset: auto tells the browser to choose the inset itself so a visible gap appears between them:
.byline a {
text-decoration: underline;
text-decoration-inset: auto; /* gap between adjacent underlines */
}Note that auto is not the same as 0: 0 means no gap, decorations touch. This value matters most in CJK typography, where underlines punctuate proper nouns and neighboring names must read as separate marks, but the byline case shows up in every language.
The Fallback (One @supports Block)
This property is brand new (Chrome 154, September 2026), so treat it as progressive enhancement. Without support, the decoration simply spans the full text width, which is the acceptable default it has always been:
.cta-link {
text-decoration: underline 3px solid currentColor;
text-underline-offset: 6px;
}
@supports (text-decoration-inset: 1px) {
.cta-link {
text-decoration-inset: 0.25em; /* trim where supported */
}
}Put the base decoration outside the query and only the inset inside. Unsupported browsers render a normal underline; nobody gets a broken link.
Quick Recap
text-decoration-inset: 0.25emtrims the decoration on both ends; two values set start and end separately.- Negative values extend the decoration past the text. The native highlighter effect.
- Animate length to length (e.g.
50%→0) for a center-out reveal; avoid transitioning fromauto. autoinserts gaps between adjacent underlines; it is not the same as0.- Gate behind
@supports. The full-width default is a fine fallback.
# Expansion draft: css-text-decoration-inset-guide
Where the Inset Lands on Wrapped Links
The inset does not trim the decoration once for the whole element. It trims each line fragment where the decoration actually paints. Take a two-line link in a narrow column: the underline on line one gets trimmed at its own start and end, and line two gets the same treatment independently. That is the behavior you want, and it is why the reveal animation from the main guide keeps working when text wraps. Each fragment animates its own inset, so the draw-in reads correctly per line instead of stretching one long line across the break.
One edge to know: with the default box-decoration-break: slice, percentage insets resolve against the full decorating box, while clone resolves them per fragment. In practice I have never needed clone for underlines. The default behavior trims wrapped links exactly the way a designer would draw it by hand.
Start and End Are Logical, Not Physical
The two-value form is text-decoration-inset: <start> <end>, and start means inline-start. In a left-to-right paragraph the start is the left edge. Switch the element to dir="rtl" and the start trim moves to the right edge without you touching the CSS.
.headline-accent {
text-decoration: underline 4px solid oklch(0.65 0.2 250);
text-decoration-inset: 0 0.6em; /* end trim follows inline-end */
}I test every asymmetric underline in RTL before shipping. It takes ten seconds: add dir="rtl" to a test wrapper and look. Underlines drawn with physical assumptions (margins, pseudo-elements positioned with left) break there. This property does not, because the spec made it logical from day one.
Pairing Inset With Offset and Thickness
Inset, offset, and thickness are three dials on one instrument, and they should all scale together. A 4px underline with a fixed 2px trim looks fine at 16px type and cramped at 48px. Put all three in em and the whole underline system scales with the font:
.u-system {
text-decoration: underline 0.09em solid currentColor;
text-underline-offset: 0.18em;
text-decoration-inset: 0.15em;
}The ratio matters more than the numbers. I keep offset slightly larger than the trim (0.18em vs 0.15em here) so the line sits clear of descenders while its ends pull in. If your trim ever exceeds the offset visually, the underline starts colliding with letters like "g" and "y" on wrapped lines. Keep the trim at or below the offset and you stay safe.
When the Inset Does Nothing: A Debugging Checklist
Four causes cover nearly every "it does nothing" report, in the order I check them. First, there is no decoration to inset. text-decoration-inset on its own paints nothing; it only modifies a text-decoration-line that is already applied. Inspect computed styles and confirm text-decoration-line is not none.
Second, the @supports gate is hiding your rule. If you wrapped the inset in @supports (text-decoration-inset: 1px) for the fallback strategy, an older Chrome silently skips it. That is the gate working as designed, not a bug, but it confuses people during testing.
Third, check the Chrome version. You need 154 or later. chrome://version settles it in seconds, and I check this before doubting my CSS every time.
Fourth, look for a competing rule with higher specificity resetting the decoration. The inset is not inherited and not part of the shorthand, so a parent rule cannot wipe it, but a later rule on the same element setting text-decoration: underline does not remove it either. What does remove the visible effect is anything that removes the line itself.
Underline Tokens for a Design System
Once two components use trimmed underlines, hard-coded values start drifting. I tokenize the three dials from the previous section:
:root {
--u-thickness: 0.09em;
--u-offset: 0.18em;
--u-trim: 0.15em;
}
.u-trimmed {
text-decoration: underline var(--u-thickness) solid currentColor;
text-underline-offset: var(--u-offset);
}
@supports (text-decoration-inset: 1px) {
.u-trimmed {
text-decoration-inset: var(--u-trim);
}
}Components override per case: a hero headline sets --u-trim: 0.1em for a bolder look, a nav link sets --u-thickness: 2px and leaves the rest. The @supports block stays in one place, in the token layer, instead of being repeated in every component. When Firefox and Safari ship the property, you change nothing. The tokens just start working everywhere.
Frequently Asked Questions
Is it part of the text-decoration shorthand?
No. It is a standalone property, not a constituent of the text-decoration shorthand, and it is not inherited. Set it alongside your existing decoration declarations.
Does it work on overlines and line-through too?
Yes. It adjusts underlines, overlines, and line-through decorations alike, since it operates on the decoration's start and end points regardless of which line it is.
What are percentage values relative to?
Percentages resolve against the inline size of the decorating box, or against each individual fragment if box-decoration-break: clone splits the text across lines. That is why 50% on both ends exactly hides the line in Recipe 3.
Which browsers support it?
Chrome 154 and later (stable September 2026), per the official release notes. During development it was called text-decoration-trim. Use the new name. Other engines have not shipped it yet, which is why the @supports gate in this guide is not optional.
Try it: related UI elements
"This is the best tool I have used for CSS this year. The generators alone saved me hours."
Testimonial Card
Copy code →
Team Member Card
Copy code →
No projects yet
Get started by creating your first project. It only takes a minute and you can invite your team later.
Learn more about projects
Empty State
Copy code →
Ship landing pages twice as fast
Copy-paste Tailwind components with live previews. Just paste and ship.
Hero Section
Copy code →