Style textDecoration Property

Definition and Usage

textDecoration Sets or returns one or more text decorations.

Tip:To specify multiple decoration types for an element, list the decoration types separated by spaces.

See also:

CSS Tutorial:CSS Text

CSS Reference Manual:text-decoration property

Example

Example 1

Set text decoration for the <p> element:

document.getElementById("myP").style.textDecoration = "underline overline";

Try It Yourself

Example 2

Returns the text decoration of the <p> element:

alert(document.getElementById("myP").style.textDecoration);

Try It Yourself

Syntax

Returns the textDecoration property:

object.style.textDecoration

Set the textDecoration property:

object.style.textDecoration = "none|underline|overline|line-through|blink|initial|inherit"

Property Value

Value Description
none Defines normal text. Default.
underline Defines a line under the text.
overline Defines a line on the text.
line-through Defines a line穿过text.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default Value: None
Return Value: A string indicating the decoration added to the text.
CSS Version: CSS1

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support