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"


流覽器支持

表格中的數字表示支持該屬性的第一個流覽器版本號。

屬性
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 文本