text-decoration

本页内容
上一节: Pr_text_text_align 下一节: Pr_text_text_indent

CSS text-decoration 属性

设置h1,h2,h3和h4元素文本装饰:


示例

h1 {text-decoration:overline}
h2 {text-decoration:line-through}
h3 {text-decoration:underline}

属性定义及使用说明

text-decoration 属性规定添加到文本的修饰,下划线、上划线、删除线等。

text-decoration 属性是以下三种属性的简写:

语法

/*关键值*/
text-decoration: none;                     /*没有文本装饰*/
text-decoration: underline red;            /*红色下划线*/
text-decoration: underline wavy red;       /*红色波浪形下划线*/

/*全局值*/
text-decoration: inherit;
text-decoration: initial;
text-decoration: unset;
默认值: none
继承: no
版本: CSS1
JavaScript 语法: object.style.textDecoration="overline"

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

属性 Chrome Internet Explorer / Edge Firefox Safari Opera
text-decoration 1.0 3.0 1.0 1.0 3.5

属性值

描述
none 默认。定义标准的文本。
underline 定义文本下的一条线。
overline 定义文本上的一条线。
line-through 定义穿过文本下的一条线。
blink 定义闪烁的文本。
inherit 规定应该从父元素继承 text-decoration 属性的值。

更多实例

示例

h1.under {
    text-decoration: underline;
}
h1.over {
    text-decoration: overline;
}
p.line {
    text-decoration: line-through;
}
p.blink {
    text-decoration: blink;
}
a.none {
    text-decoration: none;
}
p.underover {
    text-decoration: underline overline;
}

虚线与波浪线:


示例

h1 {
  text-decoration: underline overline dotted red;
}

h2 {
  text-decoration: underline overline wavy blue;
}

相关文章

CSS 教程: CSS 文本

上一节: Pr_text_text_align 下一节: Pr_text_text_indent
此页面最后编辑于2022年8月19日 (星期五) 04:48。