text-decoration-style:文字に加えられた装飾線の形状を指定する

初期値 solid
適用対象 全ての要素、::first-letterおよび::first-line
継承 しない
アニメーション 離散値
対応ブラウザ caniuseで確認

text-decoration-styleプロパティの説明

text-decoration-styleは、文字に加えられた装飾線の形状を指定します。既定値では、text-decoration-lineの値がnoneであるため、これを併記して値を変更しない限り装飾線は表示されません。

装飾線には形状の他にも色、表示位置、太さの値があります。それぞれの値は以下のプロパティで操作しますが、一括で指定できるtext-decorationというショートハンド・プロパティも用意されています。

text-decoration-styleに指定できる値

solid
単独の直線を表示します。
double
二重線を表示します。
dashed
破線を表示します。
dotted
点線を表示します。
wavy
波線を表示します。

text-decoration-styleの使い方とサンプル

text-decoration-styleプロパティの構文は以下の通りです。

CSS
/* キーワード値 */
text-decoration-style: solid;
text-decoration-style: double;
text-decoration-style: dotted;
text-decoration-style: dashed;
text-decoration-style: wavy;

/* グローバル値 */
text-decoration-style: inherit;
text-decoration-style: initial;
text-decoration-style: revert;
text-decoration-style: unset;

text-decoration-styleの実例

それでは実際にtext-decoration-styleプロパティの書き方を見ていきましょう。以下の例は、個別のプロパティで装飾線を加えた時の内容です。これらの値は、ショートハンド・プロパティのtext-decorationでも指定できます。

装飾線の範囲に意味を持たせるには、HTML要素で囲います。打ち消し線に削除や訂正の意味を持たせる場合は<del><s>、アンダーラインや波線に強調や注釈の意味を持たせる場合は<u><i>を使用します。

表示確認
CSS
.samp_box {
	padding: 1rem;
	background: #eee;
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-auto-rows: auto;
	gap: 1rem;
}
.samp_box > section {
	overflow: auto;
	padding: 0 1rem 1rem;
	background: #fff;
}
section > h2 {
	margin: 1rem 0 0;
	font-size: 1rem;
}
section > p {
	margin: .5rem 0 0;
}
.td_1 > p {
	text-decoration-line: underline;
	text-decoration-style: solid;
	text-decoration-color: currentcolor;
	text-decoration-thickness: auto;
}
.td_2 > p {
	text-decoration-line: underline;
	text-decoration-style: wavy;
	text-decoration-color: blue;
	text-decoration-thickness: 2px;
}
.td_3 > p {
	text-decoration-line: line-through;
	text-decoration-style: double;
	text-decoration-color: #f00;
	text-decoration-thickness: from-font;
}
.td_4 > p {
	text-decoration-line: underline overline;
	text-decoration-style: dotted;
	text-decoration-color: rgba(0, 0, 0, 0.5);
	text-decoration-thickness: 1px;
}
HTML
<div class="samp_box">
	<section class="td_1">
		<h2>既定の色や形状</h2>
		<p>abcdefg hijklmn opqrstu vwxyz.</p>
	</section>
	<section class="td_2">
		<h2>波線の強調</h2>
		<p>abcdefg hijklmn opqrstu vwxyz.</p>
	</section>
	<section class="td_3">
		<h2>二重の打ち消し線</h2>
		<p>abcdefg hijklmn opqrstu vwxyz.</p>
	</section>
	<section class="td_4">
		<h2>上下の二箇所を装飾</h2>
		<p>abcdefg hijklmn opqrstu vwxyz.</p>
	</section>
</div>

に関連するCSSプロパティ