Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Typography

The text-decoration-thickness property

Reference for the CSS text-decoration-thickness property: auto, from-font, lengths and percentages for underline and strike-through weight, with examples.

The text-decoration-thickness property sets how thick the underline, overline or line-through is. With the default auto the browser picks a thickness, usually based on the font. With a length or percentage you take control, which is handy for bold, designed link underlines.

CSS
a {
  text-decoration-thickness: 2px;
}

Try it

Thin to thick
Thicker on hover

Syntax

CSS
text-decoration-thickness: auto | from-font | <length> | <percentage>;
  • Initial value: auto
  • Applies to: all elements; also ::first-letter and ::first-line
  • Inherited: no
  • Animatable: yes, as a length or percentage
  • Computed value: as specified, with lengths made absolute

Values

Value Description
auto The browser chooses the thickness.
from-font Uses the thickness recommended by the font, if present; otherwise behaves like auto.
<length> A fixed thickness such as 3px or 0.1em.
<percentage> A percentage of 1em in the element's font size.

Usage notes

  • Use em for scalable lines. A thickness of 0.1em to 0.15em keeps underlines in proportion to the text.
  • Only visible with a line. Set text-decoration-line first.
  • Shorthand resets it. text-decoration: underline sets the thickness back to auto.
  • Overlap with letters. A thick underline may cross descenders such as "g"; the browser can skip ink around them, or you can push it down with text-underline-offset.
  • Applies to all line types, not only underlines.
  • Animation. Transitions on thickness work, as shown in the second example.

Browser support

Supported in current versions of all major browsers; older releases lacked it, so check a compatibility table if you need to support them.