text-decorationプロパティ
text-decorationプロパティは、テキストへの下線、上線、取り消し線、2重線などを指定するプロパティです。
色や線種も指定することができます。
CSSでは、text-decorationプロパティはテキストへの装飾という扱いです。
テキストに赤い下線を付けるといったことができます。
text-decorationプロパティは以下のプロパティの一括指定ができます。
text-decoration-lineプロパティの値は必ず指定する必要があります。
text-decoration: underline red wavy;
マーカーのような線を加えるにはbackgroundプロパティにlinear-gradient()関数を使います。
関連プロパティ
フォントやテキストを装飾するには、以下のような関連するプロパティがあります。
background:linear-gradient(); | マーカー |
font-size/line-height | 大きさ/行間 |
font-weight | 太字 |
text-decoration | 下線、上線、取り消し線、2重線など |
text-decoration-color | text-decorationの色 |
text-decoration-line | 下線、上線、取り消し線、2重線 |
text-decoration-style | 無地、波状、点線、破線、二重 |
text-shadow | テキストに影を付ける |
text-transform | 大文字、小文字、全角文字の表記 |
text-underline-position | 下線の位置の指定 |
構文(Syntax)
CSS
text-decoration: [ text-decoration-line text-decoration-color text-decoration-style ] | initial | inherit;
DOM(JavaScript)
String = object.style.textDecoration;
object.style.textDecoration="[ text-decoration-line text-decoration-color text-decoration-style ] | initial | inherit";
値(Values)
Value | 摘要 |
---|---|
text-decoration-line | 下線、上線、取り消し線、2重線など |
text-decoration-color | 線の色、CSS Colorを参照のこと |
text-decoration-style | 線の種類、点線、破線など |
initial | 初期値に戻す |
inherit | 親エレメントのプロパティを継承 |
備考(Remarks)
初期値(Default value) | none currentcolor solid |
継承(Inherited) | No |
CSS Animation | No |
Example
text-decorationの例です。テキストに赤い下線を付けるといったことに便利です。
関連(Related)
HTML、CSS、DOMのテキスト、フォント、編集用途の一覧です。
HTML
- リンク
- <a>
- テキスト
- <br>、 <h2-h6>、 <hr>、 <p>
- マーカー
- <mark>
- 書式方向
- <bdi>、 <bdo>
- 単語の扱い
- <wbr>
- プログラムコード例
- <code>、 <kbd>、 <pre>、 <samp>、 <var>
- 化学式、数式
- <sub>、 <sup>
- 削除された内容や追記された内容の補足
- <del>、 <ins>
- 引用や定義、出典を明示
- <abbr>、 <address>、 <blockquote>、 <q>、 <cite>、 <dfn>
- 日時
- <time>
- ?データ用?
- <data>
- スカラー値、ゲージ
- <meter>、 <progress>
- ルビ
- <rp>、 <rt>、 <ruby>
CSS
- フォント
- color、 font、 font-family、 font-feature-settings、 font-kerning、 font-size、 font-stretch、 font-style、 font-variant、 font-variant-caps、 font-weight
- テキスト配置
- letter-spacing、 line-height、 overflow-wrap、 tab-size、 text-align、 text-align-last、 text-combine-upright、 text-indent、 text-justify、 text-overflow、 vertical-align、 white-space、 word-break、 word-spacing、 word-wrap
- 回り込み
- clear、 float
- テキスト装飾
- text-decoration、 text-decoration-color、 text-decoration-line、 text-decoration-style、 text-shadow、 text-transform、 text-underline-position
- 書式方向
- direction、 text-orientation、 writing-mode
- 自動挿入
- content、 counter-increment、 counter-reset、 quotes
- 改行
- box-decoration-break、 hyphens
- ユーザー操作
- user-select
DOM
- インターフェイス
- ClipboardEvent
- イベント
- copy、 cut、 paste
- プロパティ
- メソッド