Style textDecoration 属性

定义和用法

textDecoration 属性设置或返回文本的一个或多个装饰。

提示:如需为一个元素规定多个装饰类型,请规定以空格分隔的装饰类型列表。

另请参阅:

CSS 教程:CSS 文本

CSS 参考手册:text-decoration 属性

实例

例子 1

为 <p> 元素设置文本装饰:

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

亲自试一试

例子 2

返回 <p> 元素的文本装饰:

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

亲自试一试

语法

返回 textDecoration 属性:

object.style.textDecoration

设置 textDecoration 属性:

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

属性值

描述
none定义普通文本。默认。
underline定义文本下的线条。
overline定义文本上的线条。
line-through定义穿过文本的线条。
initial将此属性设置为其默认值。请参阅 initial
inherit从其父元素继承此属性。请参阅 inherit

技术细节

默认值:
返回值:字符串,表示添加到文本的装饰。
CSS 版本:CSS1

浏览器支持

ChromeEdgeFirefoxSafariOpera
ChromeEdgeFirefoxSafariOpera
支持支持支持支持支持