Latest web development tutorials

HTML DOM Style textDecoration property

Style Object Reference Style Objects

Definition and Usage

textDecoration property sets or returns one or more text decoration.

Tip: If you need to modify one or more elements of a predetermined type, specify a space-separated list.

grammar

Setting textDecoration properties:

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

Back textDecoration properties:

Object.style.textDecoration

描述
none 默认。定义标准的文本。
underline 定义文本下的一条线。
overline 定义文本上的一条线。
line-through 定义穿过文本的一条线。
inherit textDecoration 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support textDecoration property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Decorative text:

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

<p id="p1">这是一些文本。</p>
<br>
<button type="button" onclick="displayResult()">装饰文本</button>

</body>
</html>

try it"


Style Object Reference Style Objects