Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. CSS
  3. Reference
  4. Properties
  5. text-decoration

text-decoration

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

* Some parts of this feature may have varying levels of support.

Thetext-decorationshorthandCSS property sets the appearance of decorative lines on text. It is a shorthand fortext-decoration-line,text-decoration-color,text-decoration-style, and the newertext-decoration-thickness property.

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>  <p>    I'd far rather be    <span>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 rulep { text-decoration: underline; } would cause the entire paragraph to be underlined. The style ruleem { text-decoration: none; } would not cause any change; the entire paragraph would still be underlined. However, the ruleem { text-decoration: overline; } would cause a second decoration to appear on "some emphasized words".

Constituent properties

This property is a shorthand for the following CSS properties:

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;

Thetext-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 asunderline orline-through.

text-decoration-color

Sets the color of the decoration.

text-decoration-style

Sets the style of the line used for the decoration, such assolid,wavy, ordashed.

text-decoration-thickness

Sets the thickness of the line used for the decoration.

Formal definition

Initial valueas each of the properties of the shorthand:
Applies toall elements. It also applies to::first-letter and::first-line.
Inheritedno
Computed valueas each of the properties of the shorthand:
Animation typeas each of the properties of the shorthand:

Formal syntax

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

<text-decoration-line> =
none|
[underline||overline||line-through||blink]|
spelling-error|
grammar-error

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

<text-decoration-style> =
solid|
double|
dotted|
dashed|
wavy

<text-decoration-color> =
<color>

<length-percentage> =
<length>|
<percentage>

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>This text has a line underneath it.</p><p>This text has a line over it.</p><p>This text has a line going through it.</p><p>  This <a 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>This text has lines above <em>and</em> below it.</p><p>  This text has a really thick purple underline in supporting browsers.</p><p>  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

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp