CSS text-decoration-thickness Property

The CSS text-decoration-thickness property controls the thickness of text decoration lines, including underlines, overlines, and strikethroughs.

It accepts the keywords auto and from-font, as well as CSS length and percentage values. This allows decoration thickness to follow the browser's default, use font information, or be customized for a particular design.

The property does not create a decoration line. Use text-decoration-line or the text-decoration shorthand to specify which decoration appears.

text-decoration-thickness Syntax

The property accepts a keyword, a non-negative CSS length, or a non-negative percentage.

Basic Syntax

.example {
  text-decoration-thickness: 2px;
}

Available Values

.example {
  text-decoration-thickness: auto;
}
.example {
  text-decoration-thickness: from-font;
}
.example {
  text-decoration-thickness: 3px;
}
.example {
  text-decoration-thickness: 0.1em;
}
.example {
  text-decoration-thickness: 10%;
}

CSS-Wide Keywords

.example {
  text-decoration-thickness: initial;
}
.example {
  text-decoration-thickness: inherit;
}
.example {
  text-decoration-thickness: unset;
}
.example {
  text-decoration-thickness: revert;
}
.example {
  text-decoration-thickness: revert-layer;
}

The initial value is auto. Because the property is not inherited, unset normally restores that initial value.

Valid Examples

a {
  text-decoration-thickness: auto;
}
.heading {
  text-decoration-thickness: from-font;
}
.custom-link {
  text-decoration-thickness: 2px;
}
.scalable-link {
  text-decoration-thickness: 0.12em;
}
.percentage-link {
  text-decoration-thickness: 12%;
}
.thin-line {
  text-decoration-thickness: 0;
}

A value of 0 is valid, although it can produce an invisible decoration line.

Invalid Examples

.example {
  text-decoration-thickness: thick;
}
.example {
  text-decoration-thickness: bold;
}
.example {
  text-decoration-thickness: -2px;
}
.example {
  text-decoration-thickness: -10%;
}
.example {
  text-decoration-thickness: 2px 4px;
}
.example {
  text-decoration-thickness: red;
}

Negative values, unsupported keywords, colors, and multiple thickness values are invalid.

Property Values

Value Description
auto Allows the browser to determine an appropriate decoration thickness.
from-font Uses thickness information from the font when available, otherwise falls back to automatic behavior.
<length> Specifies a non-negative thickness using units such as px, em, or rem.
<percentage> Specifies a non-negative thickness relative to the element's font size.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to All elements
Computed value As specified, with lengths computed to absolute lengths
Animation type By computed value type
Percentages Relative to the element's font size
Shorthand text-decoration
Specification CSS Text Decoration Module Level 4

Note: The property is not inherited. However, decorations established by a parent can propagate through descendant inline content while retaining the thickness specified by the decorating element.

How It Works

The text-decoration-thickness property determines how thick a decoration line is drawn after the decoration itself has been established.

Step 1: Create an Underline

.example {
  text-decoration-line: underline;
}

The browser draws an underline using its default thickness.

Step 2: Set a Custom Thickness

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
}

The underline is drawn with a specified thickness of 3px.

Step 3: Change the Decoration Color

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
  text-decoration-color: #2563eb;
}

The underline becomes blue while retaining its thickness.

Step 4: Change the Decoration Style

.example {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 3px;
  text-decoration-color: #2563eb;
}

The browser draws a thicker wavy underline.

Step 5: Adjust the Underline Offset

.example {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-thickness: 3px;
  text-decoration-color: #2563eb;
  text-underline-offset: 4px;
}

The underline moves farther from the text without changing its specified thickness.

Important Consideration

Changing decoration thickness affects painting rather than text layout. A very thick decoration may overlap characters or nearby content, but it does not increase the element's line height.

The auto Value

The auto keyword allows the browser to select an appropriate decoration thickness. It is the initial value.

Basic Example

.example {
  text-decoration-line: underline;
  text-decoration-thickness: auto;
}

Link Underline

a {
  text-decoration-line: underline;
  text-decoration-thickness: auto;
}

The browser determines the underline thickness.

Automatic Overline

.example {
  text-decoration-line: overline;
  text-decoration-thickness: auto;
}

Automatic Strikethrough

.example {
  text-decoration-line: line-through;
  text-decoration-thickness: auto;
}

When auto Is Useful

Automatic thickness is a practical choice for ordinary hyperlinks and body text where browser-controlled decorations are sufficient.

Important Consideration

The resulting thickness may vary with the browser, font, and operating system. The auto value does not guarantee an identical thickness across environments.

The from-font Value

The from-font keyword requests decoration thickness information from the font itself.

When the font provides appropriate metrics, the browser uses them. If the necessary information is unavailable, the browser falls back to automatic thickness.

Basic Example

.example {
  text-decoration-line: underline;
  text-decoration-thickness: from-font;
}

Heading Underline

.heading {
  font-family: Georgia, serif;
  text-decoration-line: underline;
  text-decoration-thickness: from-font;
}

Colored Font-Based Underline

.example {
  text-decoration-line: underline;
  text-decoration-color: #2563eb;
  text-decoration-thickness: from-font;
}

Combining With Underline Position

.example {
  text-decoration-line: underline;
  text-decoration-thickness: from-font;
  text-underline-position: from-font;
}

Both thickness and underline position can use font-provided information where available.

When from-font Is Useful

This value is useful when preserving the typographic characteristics of a font is more important than specifying an exact thickness.

Important Consideration

Not every font includes suitable decoration metrics. The result may match auto when the browser cannot obtain the requested information.

Length Values

CSS length values allow explicit control over decoration thickness. Common units include px, em, and rem.

Pixel Thickness

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
}

Specifies a thickness of two CSS pixels.

Thicker Pixel Underline

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 5px;
}

Creates a more prominent underline.

Relative em Thickness

.example {
  font-size: 20px;
  text-decoration-line: underline;
  text-decoration-thickness: 0.1em;
}

The thickness is calculated from the element's font size. With a 20px font size, 0.1em equals 2px.

Relative rem Thickness

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 0.125rem;
}

The thickness is calculated from the root element's font size. If the root font size is 16px, the result is 2px.

Using calc()

.example {
  text-decoration-line: underline;
  text-decoration-thickness: calc(0.1em + 1px);
}

The calculated thickness combines a font-relative value with a fixed length.

Using clamp()

.example {
  text-decoration-line: underline;
  text-decoration-thickness: clamp(1px, 0.12em, 4px);
}

The thickness is limited to a minimum of 1px and a maximum of 4px.

Zero Thickness

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 0;
}

A zero thickness is valid but can make the decoration invisible.

Important Consideration

Negative lengths are not permitted. Use non-negative values and test the result at different font sizes.

Percentage Values

Percentage values specify decoration thickness relative to the element's font size.

Basic Percentage

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 10%;
}

The underline thickness is calculated as 10% of the element's font size.

Percentage Calculation

.example {
  font-size: 20px;
  text-decoration-line: underline;
  text-decoration-thickness: 10%;
}

With a 20px font size, the specified thickness corresponds to 2px.

Larger Percentage

.example {
  font-size: 24px;
  text-decoration-line: underline;
  text-decoration-thickness: 15%;
}

At a 24px font size, 15% corresponds to 3.6px.

Responsive Font Sizing

.responsive-heading {
  font-size: clamp(20px, 3vw, 36px);
  text-decoration-line: underline;
  text-decoration-thickness: 8%;
}

The underline thickness changes with the heading's computed font size.

Percentage vs. em

.percentage-example {
  text-decoration-thickness: 10%;
}
.em-example {
  text-decoration-thickness: 0.1em;
}

Both declarations express thickness relative to font size, although percentages remain percentage values at computed-value time while relative lengths are resolved.

Important Consideration

Percentages are relative to font size, not the element's width, height, or line height. Negative percentages are invalid.

Decoration Types

The property controls thickness for the decoration lines established by text-decoration-line.

Underline Thickness

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
}

Draws an underline with the specified thickness.

Overline Thickness

.example {
  text-decoration-line: overline;
  text-decoration-thickness: 3px;
}

Draws an overline above the text.

Strikethrough Thickness

.example {
  text-decoration-line: line-through;
  text-decoration-thickness: 3px;
}

Draws a thicker line through the text.

Multiple Decoration Lines

.example {
  text-decoration-line: underline overline;
  text-decoration-thickness: 2px;
}

Both decoration lines use the same specified thickness.

All Three Decoration Lines

.example {
  text-decoration-line: underline overline line-through;
  text-decoration-thickness: 2px;
}

The thickness applies to all three decoration lines established by the element.

Important Consideration

A single declaration cannot specify different thickness values for the underline and overline of the same decoration set.

Underline Positioning

Underline thickness and underline position are separate aspects of text decoration. Adjusting both can improve the appearance of customized underlines.

Thick Underline

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 4px;
}

A thick underline may appear close to character descenders.

Adding an Offset

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 4px;
  text-underline-offset: 5px;
}

The offset moves the underline farther from its normal position.

Using Underline Position

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
  text-underline-position: under;
}

The under value positions the underline below the text's descenders where appropriate.

Using Ink Skipping

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 4px;
  text-decoration-skip-ink: auto;
}

Automatic ink skipping can interrupt an underline where it crosses glyph shapes.

Combining All Three

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
  text-decoration-skip-ink: auto;
}

This combines custom thickness, underline positioning, and automatic glyph ink skipping.

Important Consideration

Increasing thickness does not automatically move an underline away from the text. Adjust its offset or position separately when needed.

Using the text-decoration Shorthand

The text-decoration shorthand can specify decoration line, style, color, and thickness in one declaration.

Basic Thickness

.example {
  text-decoration: underline 3px;
}

Colored Underline

.example {
  text-decoration: underline #2563eb 3px;
}

Solid Underline

.example {
  text-decoration: underline solid #2563eb 3px;
}

Wavy Underline

.example {
  text-decoration: underline wavy #dc2626 2px;
}

Font-Based Thickness

.example {
  text-decoration: underline solid from-font;
}

Percentage Thickness

.example {
  text-decoration: underline solid #059669 10%;
}

Shorthand Reset Behavior

The shorthand resets its constituent longhand properties, including text-decoration-thickness.

.example {
  text-decoration-thickness: 4px;
  text-decoration: underline;
}

The second declaration resets the thickness to auto.

Preserving Custom Thickness

.example {
  text-decoration: underline;
  text-decoration-thickness: 4px;
}

The later longhand declaration applies the custom thickness.

Important Consideration

The text-decoration shorthand does not include text-underline-offset, text-underline-position, or text-decoration-skip-ink. Specify those properties separately.

Several CSS properties work together to control the appearance of text decorations.

Property Purpose
text-decoration Shorthand for decoration line, color, style, and thickness.
text-decoration-line Specifies underline, overline, and line-through decorations.
text-decoration-style Controls solid, double, dotted, dashed, and wavy decoration patterns.
text-decoration-color Controls decoration line color.
text-decoration-skip-ink Controls interruptions where underlines and overlines intersect glyph ink.
text-underline-offset Adjusts underline positioning relative to its normal position.
text-underline-position Controls the placement of underlines.

Combining Related Properties

.example {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: #2563eb;
  text-decoration-thickness: 3px;
  text-decoration-skip-ink: auto;
  text-underline-offset: 4px;
}

This creates a blue underline with custom thickness and offset while allowing automatic ink skipping.

Decoration Propagation

Text decorations established by an ancestor can propagate through descendant inline content. The decoration retains the thickness established by the decorating element.

.parent {
  text-decoration-line: underline;
  text-decoration-thickness: 4px;
}
.parent span {
  text-decoration-thickness: 1px;
}

The child's thickness declaration does not change the underline established by the parent.

Adding a Child Decoration

.parent {
  text-decoration-line: underline;
  text-decoration-thickness: 4px;
}
.parent span {
  text-decoration-line: overline;
  text-decoration-thickness: 1px;
}

The parent establishes a thicker underline, while the child establishes its own thinner overline.

Practical Examples

Standard Link Underline

a {
  text-decoration-line: underline;
  text-decoration-thickness: auto;
}

Uses the browser's automatic underline thickness.

Custom Link Underline

.custom-link {
  text-decoration-line: underline;
  text-decoration-color: #2563eb;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

Creates a clearly visible blue underline.

Font-Based Heading Underline

.heading {
  text-decoration-line: underline;
  text-decoration-thickness: from-font;
}

Uses font-provided thickness information where available.

Scalable Underline

.scalable-link {
  text-decoration-line: underline;
  text-decoration-thickness: 0.1em;
}

The underline thickness scales with the font size.

Percentage-Based Underline

.percentage-link {
  text-decoration-line: underline;
  text-decoration-thickness: 12%;
}

The underline thickness is relative to the element's font size.

Thick Decorative Heading

.decorative-heading {
  text-decoration-line: underline;
  text-decoration-color: #7c3aed;
  text-decoration-thickness: 5px;
  text-underline-offset: 6px;
}

Creates a prominent decorative underline.

Thin Overline

.overline-label {
  text-decoration-line: overline;
  text-decoration-thickness: 1px;
}

Draws a thin line above the text.

Thicker Strikethrough

.deleted-text {
  text-decoration-line: line-through;
  text-decoration-thickness: 2px;
}

Creates a more noticeable strikethrough.

Wavy Validation Underline

.invalid-text {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: #dc2626;
  text-decoration-thickness: 2px;
}

Creates a wavy underline that can accompany an accessible validation message.

Responsive Heading Underline

.responsive-heading {
  font-size: clamp(22px, 3vw, 40px);
  text-decoration-line: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
}

The underline thickness and offset scale with the heading's font size.

text-decoration-thickness Example

This example compares automatic, font-based, fixed, and relative decoration thickness values.

HTML Example

<div class="decoration-thickness-demo">
  <div class="thickness-sample">
    <strong>auto - Browser Default</strong>
    <p class="thickness-auto">CSS Text Decoration</p>
  </div>
  <div class="thickness-sample">
    <strong>from-font - Font Metrics</strong>
    <p class="thickness-font">CSS Text Decoration</p>
  </div>
  <div class="thickness-sample">
    <strong>2px - Fixed Thickness</strong>
    <p class="thickness-two">CSS Text Decoration</p>
  </div>
  <div class="thickness-sample">
    <strong>5px - Thick Underline</strong>
    <p class="thickness-five">CSS Text Decoration</p>
  </div>
  <div class="thickness-sample">
    <strong>0.1em - Relative Thickness</strong>
    <p class="thickness-em">CSS Text Decoration</p>
  </div>
  <div class="thickness-sample">
    <strong>15% - Percentage Thickness</strong>
    <p class="thickness-percent">CSS Text Decoration</p>
  </div>
</div>

CSS Example

.decoration-thickness-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.decoration-thickness-demo .thickness-sample {
  padding: 16px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}
.decoration-thickness-demo strong {
  display: block;
  margin-bottom: 12px;
  color: #334155;
  font-size: 14px;
}
.decoration-thickness-demo p {
  margin: 0;
  color: #1f2937;
  font-size: 22px;
  line-height: 1.8;
  text-decoration-line: underline;
  text-decoration-color: #2563eb;
  text-underline-offset: 4px;
}
.decoration-thickness-demo .thickness-auto {
  text-decoration-thickness: auto;
}
.decoration-thickness-demo .thickness-font {
  text-decoration-thickness: from-font;
}
.decoration-thickness-demo .thickness-two {
  text-decoration-thickness: 2px;
}
.decoration-thickness-demo .thickness-five {
  text-decoration-thickness: 5px;
}
.decoration-thickness-demo .thickness-em {
  text-decoration-thickness: 0.1em;
}
.decoration-thickness-demo .thickness-percent {
  text-decoration-thickness: 15%;
}
Browser Result
auto - Browser Default

CSS Text Decoration

from-font - Font Metrics

CSS Text Decoration

2px - Fixed Thickness

CSS Text Decoration

5px - Thick Underline

CSS Text Decoration

0.1em - Relative Thickness

CSS Text Decoration

15% - Percentage Thickness

CSS Text Decoration

Comparing the Results

Value Expected Result
auto The browser selects the decoration thickness.
from-font Uses font metrics when available, otherwise automatic thickness.
2px A fixed two-pixel underline.
5px A noticeably thicker underline.
0.1em Thickness relative to the font size.
15% Thickness equal to 15% of the font size.

The auto and from-font samples may look similar, depending on the font and browser.

Changing the Font Size

.decoration-thickness-demo p {
  font-size: 30px;
}

Relative thickness values scale with the font size, while fixed pixel values remain unchanged.

Changing the Decoration Style

.decoration-thickness-demo p {
  text-decoration-style: wavy;
}

All samples become wavy underlines while retaining their specified thickness values.

Changing the Underline Offset

.decoration-thickness-demo p {
  text-underline-offset: 7px;
}

The underlines move farther from the text without changing their specified thickness.

Accessibility Considerations

Decoration thickness can influence readability and the visibility of important text indicators.

Keep Links Recognizable

Underlines should remain visible enough for readers to identify hyperlinks.

Avoid Extremely Thin Underlines

Very thin decorations may be difficult to see on high-resolution displays or at reduced text sizes.

Avoid Excessively Thick Decorations

Thick underlines and strikethroughs can overlap characters and reduce readability.

Maintain Color Contrast

Choose decoration colors that remain distinguishable against the background.

Support Text Resizing

Consider font-relative units such as em or percentages when decoration thickness should scale with text.

Use Underline Offset When Needed

Moving a thick underline farther from the text can help prevent it from obscuring descenders.

Provide Visible Focus Indicators

Do not rely solely on underline thickness to indicate keyboard focus. Use a clear focus outline or another visible indicator.

Use Semantic HTML

Use appropriate HTML elements for links, deleted content, and other meaningful text. Decoration thickness is visual styling and does not provide semantic meaning.

Test Across Fonts

Fonts have different metrics, so the same thickness value may appear more or less prominent depending on the typeface.

Common Mistakes

Expecting Thickness to Create an Underline

.example {
  text-decoration-thickness: 3px;
}

This declaration does not create a decoration line.

Correct Example

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
}

Using an Unsupported Keyword

.example {
  text-decoration-thickness: thick;
}

Use auto, from-font, a non-negative length, or a non-negative percentage.

Using Negative Values

.example {
  text-decoration-thickness: -2px;
}

Negative thickness values are invalid.

Using Multiple Thickness Values

.example {
  text-decoration-thickness: 2px 4px;
}

Only one thickness value is permitted.

Confusing Thickness With Font Weight

.example {
  font-weight: bold;
  text-decoration-thickness: 2px;
}

Font weight changes character strokes, while decoration thickness changes the decoration line.

Confusing Thickness With Underline Offset

Thickness controls the width of the decoration stroke. Offset controls its position relative to the text.

Forgetting Shorthand Reset Behavior

.example {
  text-decoration-thickness: 4px;
  text-decoration: underline;
}

The shorthand resets the thickness to auto.

Assuming Percentages Refer to Element Width

Percentage thickness is relative to font size, not the element's width.

Assuming from-font Always Produces a Different Result

If font metrics are unavailable, from-font falls back to automatic behavior.

Expecting Child Thickness to Change Parent Decorations

A child declaration does not change the thickness of a decoration established by an ancestor.

Using Zero Thickness Accidentally

.example {
  text-decoration-thickness: 0;
}

Zero is valid but can make a decoration invisible.

Important Considerations

Keep the following points in mind when using text-decoration-thickness:

  • The property controls the thickness of text decoration lines.
  • The initial value is auto.
  • The property is not inherited.
  • It accepts auto, from-font, non-negative lengths, and non-negative percentages.
  • The auto value allows browser-controlled thickness.
  • The from-font value uses font metrics when available.
  • Fixed pixel values provide explicit thickness control.
  • Font-relative units allow thickness to scale with text.
  • Percentages are relative to font size.
  • Negative values are invalid.
  • A zero thickness is valid but may make the decoration invisible.
  • The property does not create decoration lines.
  • Use text-decoration-line to specify underlines, overlines, or strikethroughs.
  • The property works with all three decoration line types.
  • Multiple decoration lines established by one element use the same thickness.
  • The property is part of the text-decoration shorthand.
  • The shorthand resets thickness when no thickness is specified.
  • Use text-decoration-color to change decoration color.
  • Use text-decoration-style to change decoration patterns.
  • Use text-underline-offset to adjust underline position.
  • Use text-decoration-skip-ink to control glyph intersections.
  • Changing thickness does not change text layout dimensions.
  • Very thick decorations can overlap glyphs.
  • Very thin decorations may be difficult to see.
  • Decorations established by ancestors can propagate through descendant inline content.
  • A descendant's thickness does not restyle a decoration established by its ancestor.
  • Test font-based thickness with the actual fonts used on the page.
  • Use readable underline thickness for hyperlinks.
  • Test decoration visibility at different text sizes and zoom levels.

Browser Support

The CSS text-decoration-thickness property is widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.

The auto, from-font, length, and percentage values are supported in current major browsers. Older browser versions may not support all values or may render decorations differently.

For current compatibility information, visit Can I Use? and search for text-decoration-thickness.

Basic Compatibility

.example {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
}

Custom pixel thickness is supported in current major browsers.

Font-Based Thickness

.example {
  text-decoration-line: underline;
  text-decoration-thickness: from-font;
}

The browser uses font-provided thickness information where available.

Feature Detection

@supports (text-decoration-thickness: 3px) {
  .example {
    text-decoration-thickness: 3px;
  }
}

This checks whether the browser recognizes a length-based thickness declaration.

Fallback Example

.example {
  text-decoration-line: underline;
  text-decoration-thickness: auto;
  text-decoration-thickness: 0.12em;
}

Browsers that do not recognize the relative thickness declaration can retain the earlier automatic value. Browsers that do not support the property still display the underline using their normal behavior.

Testing Recommendations

Compare the results with different fonts, decoration styles, and font sizes. Test both fixed and relative thickness values to confirm that decorations remain readable.

Specifications

The text-decoration-thickness property is defined in the CSS Text Decoration Module Level 4 specification.

CSS Text Decoration Module Level 4 - text-decoration-thickness Property

The specification defines the supported thickness values and their relationship to font metrics and text decoration rendering.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: text-decoration-thickness