text-decoration-line

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.

See the Pen text-decoration-line by CSS-Tricks (@css-tricks) on CodePen.

Related

More Information

Browser Support

Chrome Safari Firefox Opera IE Android iOS
31 * † 7.1 * 6 ‡ None None None 8 *

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

Submit a Comment

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag