text-decoration-lineプロパティの説明
CSSのtext-decoration-lineプロパティは、文字に加えられた装飾線の種類を指定します。既定値では、noneの値が適用されているため装飾線は表示されません。
装飾線の種類は、アンダーライン、オーバーライン、打ち消し線などです。これらは装飾線が引かれる位置を示すものであるため、線の形状を変化させたい場合はtext-decoration-styleを使用してください。
文字に対する装飾線の値は、ショートハンド・プロパティのtext-decorationで一括操作できます。
text-decoration-color:装飾線の色text-decoration-line:装飾線の種類text-decoration-style:装飾線の形状text-decoration-thickness:装飾線の太さ
text-decoration-lineに指定できる値
none- 装飾線を表示させません。これが初期値です。
underline- 文字にアンダーラインを引きます。テキストが改行された場合は、各行の下に線が引かれます。
overline- 文字にオーバーラインを引きます。テキストが改行された場合は、各行の上に線が引かれます。
line-through- 文字に打ち消し線を引きます。テキストが改行された場合は、各行の中央に線が引かれます。
text-decoration-lineの使い方とサンプルコード
text-decoration-lineプロパティの構文は以下の通りです。
/* キーワード値 */
text-decoration-line: none;
text-decoration-line: underline;
text-decoration-line: overline;
text-decoration-line: line-through;
text-decoration-line: blink;
/* 複数のキーワード値 */
text-decoration-line: underline overline;
text-decoration-line: overline underline line-through;
/* グローバル値 */
text-decoration-line: inherit;
text-decoration-line: initial;
text-decoration-line: revert;
text-decoration-line: unset;
text-decoration-lineの実例
それでは実際にtext-decoration-lineプロパティの書き方を見ていきましょう。以下の例は、個別のプロパティで装飾線を加えた時の内容です。これらの値は、ショートハンド・プロパティのtext-decorationでも指定できます。
装飾線の範囲に意味を持たせるには、HTML要素で囲います。打ち消し線に削除や訂正の意味を持たせる場合は<del>や<s>、アンダーラインや波線に強調や注釈の意味を持たせる場合は<u>や<i>を使用します。
