Style textDecorationProperty

Style 对象参考手册Style Object

Definition and Usage

The textDecoration property sets or returns one or more text decorations.

Tip:To specify more than one decoration type for an element, specify a space-separated list.

Syntax

Set the textDecoration property:

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

Return the textDecoration property:

Object.style.textDecoration

Value Description
none Default. Defines standard text.
underline Defines a line under the text.
overline Defines a line over the text.
line-through Defines a line through the text.
inherit The value of the textDecoration property is inherited from the parent element.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the textDecoration property.

Note:IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Decorate text:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function displayResult(){
    document.getElementById("p1").style.textDecoration="underline overline";
}
</script>
</head>
<body>

<p id="p1">This is some text.</p>
<br>
<button type="button" onclick="displayResult()">Decorate text</button>

</body>
</html>

Try it yourself »


Style 对象参考手册Style Object Other Extensions