text-decoration-line

Avatar of Marie Mosley
Marie Mosley on (Updated on )

📣 Freelancers, Developers, and Part-Time Agency Owners: Kickstart Your Own Digital Agency with UACADEMY Launch by UGURUS 📣

The text-decoration-line property decorates text with an underline, overline, line-through, or a combination of those lines.

p {
  text-decoration-line: underline;
}

Values

  • none: no line is added, and any existing lines are removed — for example none removes the default underline on links.
  • underline: adds a 1px underline below the text.
  • overline: adds a 1px overline above the text.
  • line-through: adds a 1px line through the text.
  • inherit: inherits the decoration of the parent.

The value blink is in the W3C spec, but it is deprecated and will not work in any current browser. When it worked, it made the text appear to “blink” by rapidly toggling it between 0% and 100% opacity.

Combining Values

You can combine the underline, overline, or line-through values in a space-separated list to add multiple decoration lines:

p {
  text-decoration-line: overline underline line-through;
}

Usage

The text-decoration-line property is practically identical to the original text-decoration property. If all you want to do is add a line or lines to your text, text-decoration is a better choice because it it supported by every browser, even very old ones. Generally, using a text-decoration-line declaration only makes sense when you’re writing a longhand style rule that includes text-decoration-style or a text-decoration-color declaration. If you want to use all three together, you can use the shorthand text-decoration property.

Shorthand

text-decoration-line can be used in combination with text-decoration-style and text-decoration-color in the shorthand CSS3 text-decoration property (currently only Firefox fully supports this):

.underlined {
  text-decoration: underline dotted red;
}

Demo

This demo will work in Safari, Firefox, and Chrome with experimental web platform features enabled. The blink value is not included.

More Information

Browser Support

ChromeSafariFirefoxOperaIEAndroidiOS
31 * †7.1 *6 ‡NoneNoneNone8 *

* with -webkit prefix
† with experimental Web Platform features flag enabled
‡ 6 – 35 with -moz prefix, unprefixed as of 36.