text-decoration

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

text-decoration 屬性定義文字是否帶有下劃線、上劃線和/或刪除線。它是 text-decoration-linetext-decoration-style 屬性的簡寫。

文字裝飾的填充和描邊由宣告文字裝飾時的文字的填充和描邊給出。

文字裝飾的繪製順序(即填充和描邊)由宣告文字裝飾時的 paint-order 屬性的值決定。

注意: 作為表示屬性,text-decoration 還有一個對應的 CSS 屬性:text-decoration。當兩者都被指定時,CSS 屬性具有優先權。

你可以將此屬性與以下 SVG 元素一起使用

示例

html
<svg viewBox="0 0 250 50" xmlns="http://www.w3.org/2000/svg">
  <text y="20" text-decoration="underline">Underlined text</text>
  <text x="0" y="40" text-decoration="line-through">Struck-through text</text>
</svg>

用法說明

<'text-decoration-line'> || <'text-decoration-style'> || <'text-decoration-color'>
預設值 檢視單獨的屬性
可動畫的

有關值的描述,請參閱 CSS text-decoration 屬性。

規範

規範
CSS 文字裝飾模組級別 3
# text-decoration-property
Scalable Vector Graphics (SVG) 2
# TextDecorationProperties

瀏覽器相容性

另見