Spec-Zone.ru › CSS

`text-decoration` 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 CSS shorthand 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 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".

Try it

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;
}

Constituent properties

This property is a shorthand for the following CSS properties:

  • text-decoration-color
  • text-decoration-line
  • text-decoration-style
  • text-decoration-thickness

Syntax

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.

Values

text-decoration-line
Sets the kind of decoration used, such as underline or line-through.
text-decoration-color
Sets the color of the decoration.
text-decoration-style
Sets the style of the line used for the decoration, such as solid, wavy, or dashed.
text-decoration-thickness
Sets the thickness of the line used for the decoration.

Formal definition

Initial value as each of the properties of the shorthand:
  • text-decoration-color
  • text-decoration-style
  • text-decoration-line
Applies to all elements
Inherited no
Computed value as each of the properties of the shorthand:
  • text-decoration-line
  • text-decoration-style
  • text-decoration-color
  • text-decoration-thickness
Animation type as each of the properties of the shorthand:
  • text-decoration-color
  • text-decoration-style
  • text-decoration-line
  • text-decoration-thickness

Formal syntax

text-decoration = 
  <'text-decoration-line'> ||
  <'text-decoration-style'> ||
  <'text-decoration-color'> ||
  <'text-decoration-thickness'>

Examples

Demonstration of text-decoration values

.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>

Result

Specifications

Specification
CSS Text Decoration Module Level 4
# text-decoration-property
Scalable Vector Graphics (SVG) 2
# TextDecorationProperties

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
1
12
1
3.5
1
18
4
10.1
1
1.0
4.4
1
auto
87
87
70
73
26.2
87
79
62
26.2
14.0
87
26.2
blink
≤31The blink value does not have any effect.
12
3The blink value does not have any effect.
≤18The blink value does not have any effect.
1The blink value does not have any effect.
≤31The blink value does not have any effect.
4The blink value does not have any effect.
≤18The blink value does not have any effect.
1The blink value does not have any effect.
≤2.0The blink value does not have any effect.
≤4.4.3The blink value does not have any effect.
1The blink value does not have any effect.
currentColor
57
79
≤50
44
26.2
57
≤50
43
26.2
7.0
57
26.2
dashed
57
79
≤50
44
26.2
57
≤50
43
26.2
7.0
57
26.2
dotted
57
79
≤50
44
26.2
57
≤50
43
26.2
7.0
57
26.2
double
57
79
≤50
44
26.2
57
≤50
43
26.2
7.0
57
26.2
from-font
87
87
70
73
26.2
87
79
62
26.2
14.0
87
26.2
grammar-error
121
121
137
107
26.2
121
137
81
26.2
25.0
121
26.2
includes_color-and-style
57
79
6
44
26.2
8
57
6
43
26.2
8
7.0
57
26.2
8
includes_thickness
87
87
70
73
26.2
87
79
62
26.2
14.0
87
26.2
line-through
1
12
3
15
1
18
4
14
1
1.0
4.4
1
none
1
12
3
15
1
18
4
14
1
1.0
4.4
1
overline
1
12
3
15
1
18
4
14
1
1.0
4.4
1
solid
57
79
≤50
44
26.2
57
≤50
43
26.2
7.0
57
26.2
spelling-error
121
121
137
107
26.2
121
137
81
26.2
25.0
121
26.2
transparent
57
79
≤50
44
26.2
57
≤50
43
26.2
7.0
57
26.2
underline
1
12
3
15
1
18
4
14
1
1.0
4.4
1
wavy
57
79
≤50
44
26.2
57
≤50
43
26.2
7.0
57
26.2

See also

  • The individual text-decoration properties are text-decoration-line, text-decoration-color, text-decoration-style, and text-decoration-thickness.
  • The text-decoration-skip-ink, text-underline-offset, and text-underline-position properties also affect text-decoration, but are not included in the shorthand.
  • The list-style property controls the appearance of items in HTML <ol> and <ul> lists.
  • SVG 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/Reference/Properties/text-decoration

Spec-Zone.ru

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