CSS - line-height

概要

属性名 line-height
normal | <number> | <length> | <percentage> | none
初期値normal
適用可能要素すべての要素
継承継承する
メディアVisual / Linebox
サポート https://caniuse.com/mdn-css_properties_line-height

説明

行の高さを指定します。

説明
auto高さを自動計算する
<number>高さを 1.2 など、フォントサイズの倍数で指定
<length> 高さを 1.2em や 20px などの長さの単位で指定
<percentage>高さを 100% などのパーセントで指定
none親(祖先)のブロック要素のフォントサイズに依存

使用例

CSS
.sample-normal {
 line-height: normal;
 width: 400px;
 padding: 5px;
 border: 1px solid gray;
 margin-bottom: 1em;
}
.sample-200 {
 line-height: 200%;
 width: 400px;
 padding: 5px;
 border: 1px solid gray;
 margin-bottom: 1em;
}
HTML
<h3>normal</h3>
<div class="sample-normal">
この文章は、行の高さに normal を指定しています。
この文章は、行の高さに normal を指定しています。
この文章は、行の高さに normal を指定しています。
</div>
<h3>200%</h3>
<div class="sample-200">
この文章は、行の高さに 200% を指定しています。
この文章は、行の高さに 200% を指定しています。
この文章は、行の高さに 200% を指定しています。
</div>
表示
normal
この文章は、行の高さに normal を指定しています。 この文章は、行の高さに normal を指定しています。 この文章は、行の高さに normal を指定しています。
200%
この文章は、行の高さに 200% を指定しています。 この文章は、行の高さに 200% を指定しています。 この文章は、行の高さに 200% を指定しています。

詳細

line-height には単位無しの数値を指定する(推奨)

line-height には 1.5 など単位無しの数値を指定することが推奨されています。単位付きやパーセントの場合、フォントサイズの小さな子要素にも親要素の line-height が継承されてしまい、行間が広くなりすぎるのを防ぎます。

.my-parent {
 font-size: 20px;
 border: 1px solid #ccc;
 padding: .2em;
 line-height: 1.5; /* 1.5, 1.5em, 150% */
}
.my-child {
 width: 80%;
 font-size: 10px;
 border: 1px solid #ccc;
}
line-height: 1.5
あああああああああああああああああああああああああああああああああああああ
ああああああああああああああああああああああああああああああああああああああああああああああああああああああああ
line-height: 1.5em
あああああああああああああああああああああああああああああああああああああ
ああああああああああああああああああああああああああああああああああああああああああああああああああああああああ
line-height: 150%
あああああああああああああああああああああああああああああああああああああ
ああああああああああああああああああああああああああああああああああああああああああああああああああああああああ

Copyright (C) 1997-2025 杜甫々
初版:1997年7月27日、最終更新:2025年9月14日
https://www.tohoho-web.com/css/prop/line-height.htm

AltStyle によって変換されたページ (->オリジナル) /