Spec-Zone.ru › CSS

`text-decoration-thickness` CSS property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It's been available across browsers since July 2015.

The text-decoration-thickness CSS property sets the stroke thickness of the decoration line that is used on text in an element, such as a line-through, underline, or overline.

Try it

text-decoration-line: underline;
text-decoration-thickness: 3px;
text-decoration-line: line-through;
text-decoration-thickness: 0.4rem;
text-decoration-line: underline overline;
text-decoration-thickness: from-font;
font-size: 2rem;
<section id="default-example">
  <p id="example-element">
    Confusion kissed me on the cheek, and left a taste so bittersweet
  </p>
</section>
p {
  font: 1.5em sans-serif;
  text-decoration-color: red;
}

Syntax

/* Single keyword */
text-decoration-thickness: auto;
text-decoration-thickness: from-font;

/* length */
text-decoration-thickness: 0.1em;
text-decoration-thickness: 3px;

/* percentage */
text-decoration-thickness: 10%;

/* Global values */
text-decoration-thickness: inherit;
text-decoration-thickness: initial;
text-decoration-thickness: revert;
text-decoration-thickness: revert-layer;
text-decoration-thickness: unset;

Values

auto
The browser chooses an appropriate width for the text decoration line.
from-font
If 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.

Formal definition

Initial value auto
Applies to all elements
Inherited no
Percentages refer to the font size of the element itself
Computed value as specified
Animation type by computed value type

Formal syntax

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

Examples

Varying thickness

HTML

<p class="thin">Here's some text with a 1px red underline.</p>
<p class="thick">This one has a 5px red underline.</p>
<p class="shorthand">This uses the equivalent shorthand.</p>

CSS

.thin {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: red;
  text-decoration-thickness: 1px;
}

.thick {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: red;
  text-decoration-thickness: 5px;
}

.shorthand {
  text-decoration: underline solid red 5px;
}

Results

Specifications

Specification
CSS Text Decoration Module Level 4
# text-decoration-thickness-property

Note: The property used to be called text-decoration-width, but was updated in 2019 to text-decoration-thickness.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android WebView on iOS
text-decoration-thickness
89
87–89The text-decoration-thickness property has no effect unless text-underline-offset, text-decoration-color, or text-decoration-style are set to a non-initial value. See bug 40734940.
89
87–89The text-decoration-thickness property has no effect unless text-underline-offset, text-decoration-color, or text-decoration-style are set to a non-initial value. See bug 40734940.
70
75
73–75The text-decoration-thickness property has no effect unless text-underline-offset, text-decoration-color, or text-decoration-style are set to a non-initial value. See bug 40734940.
12.1
89
87–89The text-decoration-thickness property has no effect unless text-underline-offset, text-decoration-color, or text-decoration-style are set to a non-initial value. See bug 40734940.
79
63
62–63The text-decoration-thickness property has no effect unless text-underline-offset, text-decoration-color, or text-decoration-style are set to a non-initial value. See bug 40734940.
12.2
15.0
14.0–15.0The text-decoration-thickness property has no effect unless text-underline-offset, text-decoration-color, or text-decoration-style are set to a non-initial value. See bug 40734940.
89
87–89The text-decoration-thickness property has no effect unless text-underline-offset, text-decoration-color, or text-decoration-style are set to a non-initial value. See bug 40734940.
12.2
auto
87
87
70
73
12.1
87
79
62
12.2
14.0
87
12.2
from-font
87
87
70
73
12.1
87
79
62
12.2
14.0
87
12.2
percentage
87
87
74
73
17.4
87
79
62
17.4
14.0
87
17.4

See also

  • text-decoration
  • text-underline-offset

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/text-decoration-thickness

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API