text-decoration …… テキスト傍線のつけ方・色・スタイルをまとめて指定する









広告
text-decorationプロパティは、テキスト傍線のつけ方・色・スタイルをまとめて指定する際に使用します。
指定できるのは、
text-decoration-line・
text-decoration-style・
text-decoration-colorプロパティの値です。
まとめて指定する場合には、半角スペース区切りで値を記述します。
省略された値は、初期値に設定されます。
text-decorationプロパティは CSS1 や CSS2 から存在していますが、
CSS3 からはテキストの線・色・スタイルをまとめて指定できるショートハンド(短縮形)プロパティとして使用できます。
ただし、これらの値をまとめて指定すると、旧いブラウザでは無視されてしまうかもしれません。
text-decoration: underline dotted red; /* 旧いブラウザでは無視される */
text-decoration: underline; /* 併記しておくほうがベター */
text-decoration: underline; /* 併記しておくほうがベター */
■値
- text-decoration-lineプロパティの値
- none underline overline line-through blink
→text-decoration-lineのページを参照 - text-decoration-styleプロパティの値
- solid double dotted dashed wavy
→text-decoration-styleのページを参照 - text-decoration-colorプロパティの値
- 16進法やカラーネームなどで色を指定
→text-decoration-colorのページを参照
■初期値・適用対象・値の継承
- 初期値
-
text-decoration-lineは、none
text-decoration-styleは、solid
text-decoration-colorは、現在の色 - 適用対象
- すべての要素
- 値の継承
- しない
■使用例
スタイルシート部分は外部ファイル(sample.css)に記述。
p.sample1 {text-decoration: none;} p.sample2 {text-decoration: underline;} p.sample3 {text-decoration: overline;} p.sample4 {text-decoration: line-through;} p.sample5 {text-decoration: blink;} p.sample6 {text-decoration: underline dotted red;}
HTMLソース
<p class="sample1">text-decoration: none; を指定。</p> <p class="sample2">text-decoration: underline; を指定。</p> <p class="sample3">text-decoration: overline; を指定。</p> <p class="sample4">text-decoration: line-through; を指定。</p> <p class="sample5">text-decoration: blink; を指定。</p> <p class="sample6">text-decoration: underline dotted red; を指定。</p>
↓↓↓
ブラウザ上の表示
text-decoration: none; を指定。
text-decoration: underline; を指定。
text-decoration: overline; を指定。
text-decoration: line-through; を指定。
text-decoration: blink; を指定。
text-decoration: underline dotted red; を指定。
広告