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
Syntax
CSS
text-decoration-thickness: auto | from-font | <length> | <percentage>;
- Initial value:
auto - Applies to: all elements; also
::first-letterand::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
emfor scalable lines. A thickness of0.1emto0.15emkeeps underlines in proportion to the text. - Only visible with a line. Set
text-decoration-linefirst. - Shorthand resets it.
text-decoration: underlinesets the thickness back toauto. - 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.
Related
text-decorationโ the shorthandtext-underline-offsetโ distance from the texttext-decoration-styleโ the line pattern- Lesson: Styling Text