This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The text-decoration shorthand CSS property sets the appearance of decorative lines on text. It is a shorthand for text-decoration-line, text-decoration-color, text-decoration-style, and the newer text-decoration-thickness property.
text-decoration: underline;
text-decoration: underline dotted;
text-decoration: underline dotted red;
text-decoration: green wavy underline;
text-decoration: underline overline #ff3028;
<section id="default-example">
<p>
I'd far rather be
<span class="transition-all" id="example-element">happy than right</span>
any day.
</p>
</section>
p {
font: 1.5em sans-serif;
}
Text decorations are drawn across descendant text elements. This means that if an element specifies a text decoration, then a child element can't remove the decoration. For example, in the markup <p>This text has <em>some emphasized words</em> in it.</p>, the style rule p { text-decoration: underline; } would cause the entire paragraph to be underlined. The style rule em { text-decoration: none; } would not cause any change; the entire paragraph would still be underlined. However, the rule em { text-decoration: overline; } would cause a second decoration to appear on "some emphasized words".
This property is a shorthand for the following CSS properties:
text-decoration: underline; text-decoration: overline red; text-decoration: none; /* Global values */ text-decoration: inherit; text-decoration: initial; text-decoration: revert; text-decoration: revert-layer; text-decoration: unset;
The text-decoration property is specified as one or more space-separated values representing the various longhand text-decoration properties.
text-decoration-lineSets the kind of decoration used, such as underline or line-through.
text-decoration-colorSets the color of the decoration.
text-decoration-styleSets the style of the line used for the decoration, such as solid, wavy, or dashed.
text-decoration-thicknessSets the thickness of the line used for the decoration.
| Initial value | as each of the properties of the shorthand:
|
|---|---|
| Applies to | all elements. It also applies to ::first-letter and ::first-line. |
| Inherited | no |
| Computed value | as each of the properties of the shorthand:
|
| Animation type | as each of the properties of the shorthand:
|
text-decoration =
<'text-decoration-line'> ||
<'text-decoration-style'> ||
<'text-decoration-color'>
<text-decoration-line> =
none |
[ underline || overline || line-through || blink ]
<text-decoration-style> =
solid |
double |
dotted |
dashed |
wavy
<text-decoration-color> =
<color>
.under {
text-decoration: underline red;
}
.over {
text-decoration: wavy overline lime;
}
.line {
text-decoration: line-through;
}
.plain {
text-decoration: none;
}
.underover {
text-decoration: dashed underline overline;
}
.thick {
text-decoration: solid underline purple 4px;
}
.blink {
text-decoration: blink;
}
<p class="under">This text has a line underneath it.</p> <p class="over">This text has a line over it.</p> <p class="line">This text has a line going through it.</p> <p> This <a class="plain" href="#">link will not be underlined</a>, as links generally are by default. Be careful when removing the text decoration on anchors since users often depend on the underline to denote hyperlinks. </p> <p class="underover">This text has lines above <em>and</em> below it.</p> <p class="thick"> This text has a really thick purple underline in supporting browsers. </p> <p class="blink"> This text might blink for you, depending on the browser you use. </p>
| 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 |
1 | 12 | 1 | 3.5 | 1 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
includes_color-and-style |
57 | 79 | 6 | 44 | 8 | 57 | 6 | 43 | 8 | 7.0 | 57 | 8 |
includes_thickness |
87 | 87 | 70 | 73 | No | 87 | 79 | 62 | No | 14.0 | 87 | No |
text-decoration-line, text-decoration-color, text-decoration-style, and text-decoration-thickness.text-decoration-skip-ink, text-underline-offset, and text-underline-position properties also affect text-decoration, but are not included in the shorthand.list-style property controls the appearance of items in HTML <ol> and <ul> lists.text-decoration attribute
© 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/text-decoration