text-decorationプロパティの説明
CSSのtext-decorationプロパティは、文字の装飾線に関する値を一括で指定します。本プロパティは装飾線の色、種類、形状、太さをまとめて操作するショートハンド・プロパティです。
文字に対する装飾線の値を個別に指定する場合は、以下のプロパティを使用してください。
text-decoration-color:装飾線の色text-decoration-line:装飾線の種類text-decoration-style:装飾線の形状text-decoration-thickness:装飾線の太さ
text-decorationに指定できる値
text-decoration-colortext-decoration-colorに該当する値です。文字に対する装飾線の色を指定します。text-decoration-linetext-decoration-lineに該当する値です。文字に対する装飾線の種類を指定します。text-decoration-styletext-decoration-styleに該当する値です。文字に対する装飾線の形状を指定します。text-decoration-thicknesstext-decoration-thicknessに該当する値です。文字に対する装飾線の太さを指定します。
text-decorationの使い方とサンプルコード
text-decorationプロパティの構文は以下の通りです。
/* line */
text-decoration: none;
text-decoration: underline;
text-decoration: overline line-through;
/* line | color */
text-decoration: underline black;
text-decoration: line-through #f00;
/* line | style | color */
text-decoration: underline dashed gray;
text-decoration: line-through wavy #f00;
/* line | style | color | thickness */
text-decoration: underline dashed gray 1px;
text-decoration: line-through wavy #f00 0.5rem;
/* グローバル値 */
text-decoration: inherit;
text-decoration: initial;
text-decoration: revert;
text-decoration: revert-layer;
text-decoration: unset;
text-decorationの実例
それでは実際にtext-decorationプロパティの書き方を見ていきましょう。以下の例は、文字に装飾線を加えた表現の比較です。一般的なアンダーラインから、強調を示す波線、打ち消し線などの実用的なものまで、様々な視覚効果を加えることができます。
打ち消し線に削除や訂正の意味を持たせる場合は、HTMLの<del>や<s>を使用しましょう。アンダーラインや波線による強調に意味を持たせるには、<u>や<i>で囲いスタイルを指定すると良いでしょう。
