text-decoration (CSS property)

Spec
Inherited Initial Version
No none CSS1, 2
Browser support (more…)
IE8+ FF1+ SA1.3+ OP9.2+ CH2+
Full Buggy Buggy Full Buggy

Syntax

text-decoration: { { blink | line-through | overline | underline }  … | none | inherit } ;

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.

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;
}

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

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Buggy Buggy Buggy Full Buggy Buggy Buggy Buggy Buggy Buggy Buggy Buggy Buggy Full Full Full Buggy

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 version 8 doesn’t support the blink property.

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 3.5; Safari up to and including version 4; Chrome up to and including version 3; all propagate text decoration values to floating descendants.

User-contributed notes

There are no comments yet.

Related Products