CSS text-decoration 屬性
- 上一頁 text-align-last
- 下一頁 text-decoration-color
定義和用法
text-decoration 屬性規定添加到文本的修飾。
注釋:修飾的顏色由 "color" 屬性設置。
說明
這個屬性允許對文本設置某種效果,如加下劃線。如果后代元素沒有自己的裝飾,祖先元素上設置的裝飾會“延伸”到后代元素中。不要求用戶代理支持 blink。
另請參閱:
CSS 教程:CSS 文本
HTML DOM 參考手冊:textDecoration 屬性
實例
設置 h1、h2、h3、h4 元素的文本修飾:
h1 {text-decoration:overline;} h2 {text-decoration:line-through;} h3 {text-decoration:underline;} h4 {text-decoration:blink;}
CSS 語法
text-decoration: text-decoration-line text-decoration-color text-decoration-style text-decoration-thickness|initial|inherit;
屬性值
值 | 描述 |
---|---|
text-decoration-line | 設置要使用的文本裝飾類型(如下劃線、上劃線、劃線)。 |
text-decoration-color | 設置文字裝飾的顏色。 |
text-decoration-style | 設置文本裝飾的樣式(如實心、波浪形、點線、虛線、雙線)。 |
text-decoration-thickness | 設置裝飾線的粗細。 |
initial | 將此屬性設置為其默認值。請參閱 initial。 |
inherit | 從其父元素繼承此屬性。請參閱 inherit。 |
技術細節
默認值: | none |
---|---|
繼承性: | no |
版本: | CSS1 |
JavaScript 語法: | object.style.textDecoration="overline" |
更多實例
- 修飾文本
- 本例演示如何向文本添加修飾。
瀏覽器支持
表格中的數字注明了完全支持該屬性的首個瀏覽器版本。
Chrome | IE / Edge | Firefox | Safari | Opera |
---|---|---|---|---|
1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
- 上一頁 text-align-last
- 下一頁 text-decoration-color