GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

`text-decoration` CSS property

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.

The **`text-decoration`** [CSS](/docs/Web/CSS) [shorthand](/docs/Web/CSS/Guides/Cascade/Shorthand_properties) 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".

CSS Demo: text-decoration

```css interactive-example-choice
text-decoration: underline;
```

```css interactive-example-choice
text-decoration: underline dotted;
```

```css interactive-example-choice
text-decoration: underline dotted red;
```

```css interactive-example-choice
text-decoration: green wavy underline;
```

```css interactive-example-choice
text-decoration: underline overline #ff3028;
```

```html interactive-example
<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>
```

```css interactive-example
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

```css
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

## Formal syntax

## Examples

### Demonstration of text-decoration values

```css
.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;
}
```

```html
<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

auto

## Specifications

## Browser compatibility

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

source: MDN Web Docs mirror · page

Cite this

"`text-decoration` CSS property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/text-decoration

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·