Skip to: content, navigation

by Tommy Olsson and Paul O’Brien

text-decoration (CSS property)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Buggy Buggy Full Full
Spec
Inherited Initial Version
No none CSS1, 2
text-decoration: { { blink | line-through | overline | underline }  … | none | inherit } ;

Example

With the following rules applied, unvisited anchor links are bold, but have no underline, visited links have a line through them, and links in the hover or focus state have a line above and below them:

a:link {
  font-weight: bold;
  text-decoration: none;
}
a:visited {
  font-weight: bold;
  text-decoration: line-through;
}
a:hover, a:focus {
  text-decoration: underline overline;
}

Try it yourself!View all demos

Description

This property specifies the decorations that will be applied to the text content of an element. These decorations are rendered in the color specified by the element’s color property.

The text decorations are not technically inherited, but the effect is similar to inheritance. If they’re set on an inline element, they apply to all boxes generated by that element. If they’re set on a block-level element, the setting is applied to an anonymous inline box that encompasses all inline children in the normal flow, and also to all block-level descendants in the normal flow. The decorations are not propagated to floated or absolutely positioned descendants, or to descendant inline tables or inline blocks.

Also, text decorations on inline boxes are rendered along the entire box, even if it contains descendant boxes. This, too, may appear similar to inheritance. Any text decoration setting on a descendant box can never “undo” the text decorations of an ancestor box.

Value

blink
This value makes the text blink. (Conforming user agents are allowed to ignore this value, since blinking content can be detrimental to a page’s accessibility.)
line-through
This value draws a horizontal line through the text.
none
This value produces no text decoration (although it doesn’t undo a decoration that’s set on an ancestor element).
overline
This value draws a horizontal line above the text.
underline
This value draws a horizontal line below the text.

Compatibility

IE5.5Buggy
6.0Buggy
7.0Buggy
Firefox1.0Buggy
1.5Buggy
2.0Buggy
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Internet Explorer for Windows versions up to and including 7 don’t support the blink property. Setting the value to none will remove all text decorations from an element, even if one or more decorations are specified for its parent element. Text decorations are propagated to floating and absolutely positioned descendants.

Internet Explorer for Windows versions up to and including 6 place the line-through line noticeably higher above the baseline than other browsers.

Internet Explorer for Windows versions up to and including 7 don’t support the value inherit.

Firefox versions up to and including 2 propagate text decoration values to floating descendants.

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters