CSS Attributes Index Text Attributes
Sets or retrieves whether the text in the object has blink, line-through, overline, or underline decorations.
CSS |
{ text-decoration: 'none' || 'underline' || 'overline' || 'line-through' || 'blink' } |
Script |
object.style.textAlign = sDecoration ] |
none |
Text has no decoration. |
underline |
Text is underlined. |
overline |
Text has a line over it. |
line-through |
Text has a line drawn through it. |
blink |
Text blinks. |
The property is read/write with a default value of none ( see the Remarks section ); this attribute is not inherited.
The default value is none, with these exceptions:
- The following tags have a default value of underline: A with href, U, and INS.
- The following tags have a default value of line-through: STRIKE, S, and DEL.
If the value none is placed at the end of the values, all values will be cleared. For example, setting {text-decoration: underline overline blink none} would result in none of the decorations rendering.
If the object has no text ( for example, the IMG object in HTML ) or is an empty object ( for example, "<EM> </EM>" ), this property has no effect.
If the text-decoration attribute is set to none on the BODY object, A objects will still be underlined. To remove the underline on A objects, either set the style inline or use A as a selector in the global stylesheet.
Specifying the textDecoration property for block elements will affect all inline children. If it is specified for, or affects, an inline element, it will affect all boxes generated by the element.
The overline and blink possible values are available as of Microsoft® Internet Explorer® 4.0 or later. Although blink is exposed, it is not rendered.
The following example demonstrates the effects of applying the different values possible for the CSS text-decoration attribute.
Show me
The sample below uses inline event handlers to dynamically change an object’s textDecoration property in response to mouse events.
<p onmouseover="this.style.textDecoration='underline'"
onclick="this.style.textDecoration='overline'"
ondblclick="this.style.textDecoration='line-through'"
onmouseout="this.style.textDecoration=''">
...
</p>
Show me
textDecorationBlink, textDecorationLineThrough, textDecorationNone, textDecorationOverline, textDecorationUnderline