CSS - word-break
概要
| 属性名 | word-break |
|---|---|
| 値 | normal | break-all | break-word | keep-all | auto-phrase |
| 初期値 | normal |
| 適用可能要素 | すべての要素 |
| 継承 | 継承する |
| メディア | Visual / Text |
| サポート | https://caniuse.com/?search=word-break |
説明
和文や英文などの文字間、単語間、文節間、文章間で表示幅に合わせた自動改行を行うか否かを指定します。ここで和文等とは日本語、中国語、韓国語などのように単語の境界にスペース文字を用いない言語を指します。英文等とは英語やドイツ語などのように単語の境界にスペース文字を用いる言語を指します。文節は「風の/谷の/ナウシカ」などのように間に喋る際に間に少し間を開けても不自然ではない単位を指します。
| 値 | 説明 |
|---|---|
| normal | 和文等は文字間で自動改行します。英文等は単語間で自動改行し、横幅が収まりきらない場合ははみだします。 |
| break-all | 和文等は文字間で自動改行します。英文等は文字間で自動改行し、横幅が収まりきらない場合は文字間でも自動改行します。 |
| break-word | 和文等は文字間で自動改行します。英文等は単語間で自動改行し、横幅が収まりきらない場合は文字間でも自動改行します。 |
| keep-all | 和文等は文章間で自動改行します。英文等は単語間で自動改行し、横幅が収まりきらない場合ははみだします。 |
| auto-phrase | 和文等は文節間で自動改行します。英文等は単語間で自動改行し、横幅が収まりきらない場合ははみだします。 |
長い英単語を単語の途中で改行する場合、改行位置にハイフン(-)を表示することができます。詳細は hyphens を参照してください。
使用例
CSS
.my-box {
margin: 1em;
border: 1px solid #ccc;
width: 11rem;
}
.wb-normal { word-break: normal; }
.wb-break-all { word-break: break-all; }
.wb-break-word { word-break: break-word; }
.wb-keep-all { word-break: keep-all; }
.wb-auto-phrase { word-break: auto-phrase; }
HTML
<div class="my-box wb-xxxxxxxx"> The most long word is pneumonoultramicroscopicsilicovolcanoconiosis. This is English sentence. This is English sentence. これは日本語の長い長い長い長い文章です。これは日本語の長い長い長い長い文章です。 </div>
表示
normal
The most long word is pneumonoultramicroscopicsilicovolcanoconiosis.
This is English sentence. This is English sentence.
これは日本語の長い長い長い長い文章です。これは日本語の長い長い長い長い文章です。
break-all
The most long word is pneumonoultramicroscopicsilicovolcanoconiosis.
This is English sentence. This is English sentence.
これは日本語の長い長い長い長い文章です。これは日本語の長い長い長い長い文章です。
break-word
The most long word is pneumonoultramicroscopicsilicovolcanoconiosis.
This is English sentence. This is English sentence.
これは日本語の長い長い長い長い文章です。これは日本語の長い長い長い長い文章です。
keep-all
The most long word is pneumonoultramicroscopicsilicovolcanoconiosis.
This is English sentence. This is English sentence.
これは日本語の長い長い長い長い文章です。これは日本語の長い長い長い長い文章です。
auto-phrase
The most long word is pneumonoultramicroscopicsilicovolcanoconiosis.
This is English sentence. This is English sentence.
これは日本語の長い長い長い長い文章です。これは日本語の長い長い長い長い文章です。
Copyright (C) 1997-2025 杜甫々
初版:1997年7月27日、最終更新:2025年12月14日
https://www.tohoho-web.com/css/prop/word-break.htm