css教程网 css教程网365css.cn
公告为您打开互联网世界的窗户关于本站

text-decoration

下划线、删除线、上划线,可分别控制线型、颜色与粗细。

语法
text-decoration: <line> || <style> || <color> || <thickness>
常用值
none / underline / line-through;underline dotted #2b57ff
初始值
none
继承
否(但会绘制到子元素)

运行效果

示例改成别的值试试,差异一眼能看出来
查看代码
HTML
<p class="td"><a href="#">带下划线的链接</a> <span class="del">已删除</span></p>
CSS
.td { font-size: 13px; }
.td a { color: #2b57ff; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.td .del { color: #98a1b0; text-decoration: line-through; }

使用要点

  • 链接不要只靠颜色区分,加下划线对色盲用户更友好。
  • text-underline-offset 控制下划线与文字的距离,跳出行高更清晰。