Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Typography

The text-underline-offset property

Reference for the CSS text-underline-offset property: moving underlines away from the text, auto, lengths and percentages, and clean link styling.

The text-underline-offset property sets how far an underline sits from its default position under the text. A bigger offset moves the line down, so it no longer collides with descenders (the tails of "g", "p", "y"). A small offset keeps it snug against the letters. It affects underlines only, not overlines or line-throughs.

CSS
a {
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
}

Try it

Underline distance
A nicer link style

Syntax

CSS
text-underline-offset: auto | <length> | <percentage>;
  • Initial value: auto
  • Applies to: all elements; also ::first-letter and ::first-line
  • Inherited: yes
  • Animatable: yes, as a length or percentage
  • Computed value: auto, or an absolute length

Values

Value Description
auto The browser chooses the position.
<length> Distance from the default underline position, such as 4px or 0.2em. Positive moves the line away from the text.
<percentage> A percentage of 1em in the element's font size.

Usage notes

  • Underlines only. Overlines and line-throughs ignore it.
  • Relative to the auto position. The offset is measured from the position that text-underline-position establishes, not from the baseline directly.
  • Use em for scalable results. Then the offset follows the font size.
  • Inherited. Unlike most decoration properties, this one is inherited, so a value on a container applies to the links inside.
  • Combine with thickness. A thicker line usually needs a larger offset so the letters stay clear.
  • Avoid collisions with the next line. A large offset in tightly spaced text may bring the underline close to the line below. Check with real content.
  • Accessibility. Keep underlines visible and consistent for links; that is a primary cue for people who cannot rely on color.

Browser support

Supported in current versions of all major browsers; older releases may lack it, so check a compatibility table.