text-decoration-thickness:文字に加えられた装飾線の太さを指定する

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

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

text-decoration-thicknessは、文字に加えられた装飾線の太さを指定します。既定値では、ブラウザが自動的に計算した太さで表示します。フォントのファイルに推奨する太さの情報が含まれている場合は、その値を使用することもできます。

文字に装飾線を加える場合は、まず初めにtext-decoration-lineで線の種類を指定します。初期値では、これがnoneになっているため、太さを変えても表示されません。

装飾線は色や形状を変化させることも可能です。それぞれの値は以下のプロパティで操作しますが、一括で指定できるtext-decorationというショートハンド・プロパティも用意されています。

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

auto
ブラウザが自動で計算した値を採用します。
from-font
フォントファイルに推奨する太さの情報が含まれている場合は、その値を使用します。その情報が含まれていない場合は、autoと同じ動作になります。
<length>
装飾線の太さを長さを表す単位つきの値で指定します。太さによっては文字が読めなくなったり、他の要素に重なってしまうことがあるため、十分に検証してから本番環境に実装しましょう。
<percentage>
装飾線の太さを現在のフォントの1emに対する割合で算出します。フォントサイズの値は継承するため、入れ子構造になっている要素に適用した場合は、意図しない太さになることがあります。

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

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

CSS
/* キーワード値 */
text-decoration-thickness: auto;
text-decoration-thickness: from-font;

/* <length>値 */
text-decoration-thickness: 1px;
text-decoration-thickness: 0.1em;

/* <percentage>値 */
text-decoration-thickness: 10%;

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

text-decoration-thicknessの実例

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

text-decoration-thicknessに関連するCSSプロパティ

テキスト関連
text-align ボックスに含まれる内容の横位置の揃え方を指定する
text-align-last ボックスに含まれる内容の最後の行を揃える位置を指定する
text-combine-upright 一文字分の空間に挿入する文字の組み合わせを指定する
text-decoration 文字の装飾線に関する値を一括で指定する
text-decoration-color 文字に加えられた装飾線の色を指定する
text-decoration-line 文字に加えられた装飾線の種類を指定する
text-decoration-skip-ink 装飾線が文字を通過する祭の処理を指定する
text-decoration-style 文字に加えられた装飾線の形状を指定する
text-decoration-thickness 文字に加えられた装飾線の太さを指定する
text-emphasis テキストに付加する圏点、傍点、脇点に関する値を一括で指定する
text-emphasis-color テキストに付加する圏点、傍点、脇点の色を指定する
text-emphasis-position テキストに付加する圏点、傍点、脇点の位置を指定する
text-emphasis-style テキストに付加する圏点、傍点、脇点の記号を指定する
text-indent テキストの一行目に挿入するインデントの幅を指定する
text-justify テキストの行端揃えに対して均等割り付けの方法を指定する
text-orientation 縦書きモードの文字の向きを指定する
text-overflow 行からテキストが溢れている状態の表現方法を指定する
text-shadow 文字に影(ドロップシャドウ)を付ける
text-transform テキストの大文字・小文字の表記を指定する
text-underline-position 文字の下に引かれる装飾線の位置を指定する