CSS Portal

CSS text-decoration-thickness Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The text-decoration-thickness property controls the thickness of decorations drawn on text — such as underlines, overlines, and line-throughs — independent of the glyph outlines themselves. Rather than changing the stroke of the font, it determines how thick the decorative line that sits above, below, or through the text will be. This lets you make underlines more delicate or more prominent than the browser or font defaults, which is useful for typography refinement, branding, and ensuring visibility against different backgrounds.

In practice, the visual result of text-decoration-thickness depends on font metrics, device pixel density, and the way the user agent renders hairlines and subpixel lines. Thin values may end up as single-pixel hairlines on some screens, while thicker settings scale up and can interact with line gaps and ascenders/descenders of the typeface. When you use larger sizes or apply transforms/zoom, the decoration thickness scales along with the text, but how it relates to stroke-like properties of glyphs varies by rendering engine — so testing across sizes and fonts is recommended to keep decorations from looking disproportionate or from colliding with glyphs.

This property is often used in combination with other decoration-related properties to achieve a complete visual effect: the overall decoration type is still controlled by text-decoration, the vertical placement can be adjusted with text-underline-offset, and the perceived weight of the text itself can influence how thick a decoration should appear (for example, via font-weight). Coordinating these properties lets you create underlines that feel consistent with type weight and style — for instance, slightly thicker underlines for bold text or increased offset when decorations become thick enough to risk touching lowercase letters.

From a practical and accessibility standpoint, use text-decoration-thickness to improve readability and maintain visual hierarchy: subtle underlines for body links, stronger lines for important calls to action, or delicate overlines for stylistic accents. Be mindful of contrast, overlap with diacritics, and responsive behavior — prefer values or strategies that scale with font size so decorations remain proportional across breakpoints and user-scaled text.

Definition

Initial value
auto
Applies to
all elements. It also applies to ::first-letter and ::first-line.
Inherited
no
Computed value
as specified
Animatable
by computed value type
JavaScript syntax
object.style.textDecorationThickness

Interactive Demo

The rusty swing set creaked.

Syntax

text-decoration-thickness: auto | from-font | <length> | <percentage>

Values

  • autoThe browser chooses an appropriate width for the text decoration line.
  • from-fontIf the font file includes information about a preferred thickness, use that value. If the font file doesn't include this information, behave as if auto was set, with the browser choosing an appropriate thickness.
  • <length>Specifies the thickness of the text decoration line as a <length>, overriding the font file suggestion or the browser default.
  • <percentage>Specifies the thickness of the text decoration line as a <percentage> of 1em in the current font. A percentage inherits as a relative value, and so therefore scales with changes in the font. The browser must use a minimum of 1 device pixel. For a given application of this property, the thickness is constant across the whole box it is applied to, even if there are child elements with a different font size.

Example

<div class="example">
<h1 class="title">text-decoration-thickness examples</h1>
<p class="demo thin">Thin underline (0.1em)</p>
<p class="demo medium">Medium underline (2px)</p>
<p class="demo thick">Thick underline (4px, double)</p>
<p class="demo from-font">From-font thickness (from-font)</p>
<p class="demo underline-offset">Underline with offset + thickness</p>
<a href="#" class="demo link">Decorated link (wavy)</a>
</div>
/* Highlight examples of text-decoration-thickness */
:root {
  --accent: #0066cc;
  --muted: #222;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  margin: 40px;
  color: var(--muted);
  background: #ffffff;
}

.example {
  max-width: 700px;
  margin: 0 auto;
}

.title {
  margin-bottom: 16px;
  font-size: 20px;
  color: #111;
}

.demo {
  margin: 12px 0;
  font-size: 18px;
}

.demo.thin {
  text-decoration: underline;
  text-decoration-color: #c33;
  text-decoration-thickness: 0.1em;
  text-decoration-style: solid;
  text-underline-offset: 4px;
}

.demo.medium {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-decoration-style: solid;
}

.demo.thick {
  text-decoration: underline;
  text-decoration-color: #2a9d8f;
  text-decoration-thickness: 4px;
  text-decoration-style: double;
}

.demo.from-font {
  text-decoration: underline;
  text-decoration-color: #000;
  text-decoration-thickness: from-font;
}

.demo.underline-offset {
  text-decoration: underline;
  text-decoration-color: #e76f51;
  text-decoration-thickness: 0.35em;
  text-underline-offset: 6px;
}

.demo.link {
  display: inline-block;
  text-decoration-color: #8a2be2;
  text-decoration-thickness: 3px;
  text-decoration-style: wavy;
  padding: 6px 0;
}

Browser Support

The following information will show you the current browser support for the CSS text-decoration-thickness property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!