大网数据广告活动
Web 标准与前端开发

text-decoration-style

· 52CE 我爱测

CSS 属性 **`text-decoration-style`** 用于设置由 text-decoration-line 设定的线的样式。线的样式会应用到所有被 `text-decoration-line` 设定的线,不能为其中的每条线设置不同的样式。当要设置多个线修饰属性时,用 text-decoration 简写属性会比分别写多个属性更方便。

CSS 属性 text-decoration-style 用于设置由 text-decoration-line 设定的线的样式。线的样式会应用到所有被 text-decoration-line 设定的线,不能为其中的每条线设置不同的样式。当要设置多个线修饰属性时,用 text-decoration 简写属性会比分别写多个属性更方便。

CSS Demo: text-decoration-style

text-decoration-style: solid;
text-decoration-style: double;
text-decoration-style: dotted;
text-decoration-style: dashed;
text-decoration-style: wavy;
<section id="default-example">
  <p>
    I'd far rather be
    <span class="transition-all" id="example-element">happy than right</span>
    any day.
  </p>
</section>
p {
  font: 1.5em sans-serif;
}

#example-element {
  text-decoration-line: underline;
}

如果设定的修饰效果具有特定的语义,例如删除线的意味着某些文本被删除了,开发者最好使用有语义的 HTML 标签来表达,比如 del 或 s 标签,因为浏览器有时可能会屏蔽某些样式,但语义化的标签则不会出现这样的问题。

当一次使用多个 line-decoration 属性时,使用 text-decoration 简写属性会更方便。

语法

/* Keyword values */
text-decoration-style: solid;
text-decoration-style: double;
text-decoration-style: dotted;
text-decoration-style: dashed;
text-decoration-style: wavy;

/* Global values */
text-decoration-style: inherit;
text-decoration-style: initial;
text-decoration-style: unset;

值

  • solid
    • : 画一条实线。
  • double
    • : 画一条双实线。
  • dotted
    • : 画一条点划线。
  • dashed
    • : 画一条虚线。
  • wavy
    • : 画一条波浪线。
  • -moz-none
    • : 不画线。亦可用 text-decoration-line: none 替代。

形式语法

示例

.example {
  -moz-text-decoration-line: underline;
  -moz-text-decoration-style: wavy;
  -moz-text-decoration-color: red;
  -webkit-text-decoration-line: underline;
  -webkit-text-decoration-style: wavy;
  -webkit-text-decoration-color: red;
}
.wavy {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: red;
}
<p class="wavy">This text has a wavy red line beneath it.</p>

示例

规范

浏览器兼容性

参见

  • 当要设置多个线修饰属性时,用 text-decoration 简写属性会比分别写多个属性更方便

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。