word-break CSS property sets whether line breaks appear wherever the text would otherwise overflow its content box.

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

句法

/* Keyword values */
word-break: normal;
word-break: break-all;
word-break: keep-all;
word-break: break-word; /* deprecated */
/* Global values */
word-break: inherit;
word-break: initial;
word-break: unset;
					

word-break property is specified as a single keyword chosen from the list of values below.

normal

Use the default line break rule.

break-all

To prevent overflow, word breaks should be inserted between any two characters (excluding Chinese/Japanese/Korean text).

keep-all
Word breaks should not be used for Chinese/Japanese/Korean (CJK) text. Non-CJK text behavior is the same as for normal .
break-word
Has the same effect as word-break: normal and overflow-wrap: anywhere , regardless of the actual value of the overflow-wrap 特性。

注意: In contrast to word-break: break-word and overflow-wrap: break-word (见 overflow-wrap ), word-break: break-all will create a break at the exact place where text would otherwise overflow its container (even if putting an entire word on its own line would negate the need for a break).

形式定义

初始值 normal
适用于 所有元素
继承 yes
计算值 如指定
动画类型 discrete

形式句法

normal | break-all | keep-all | break-word
					

范例

HTML

<p>1. <code>word-break: normal</code></p>
<p class="normal narrow">This is a long and
 Honorificabilitudinitatibus califragilisticexpialidocious Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu
 グレートブリテンおよび北アイルランド連合王国という言葉は本当に長い言葉</p>
<p>2. <code>word-break: break-all</code></p>
<p class="breakAll narrow">This is a long and
 Honorificabilitudinitatibus califragilisticexpialidocious Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu
 グレートブリテンおよび北アイルランド連合王国という言葉は本当に長い言葉</p>
<p>3. <code>word-break: keep-all</code></p>
<p class="keepAll narrow">This is a long and
 Honorificabilitudinitatibus califragilisticexpialidocious Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu
 グレートブリテンおよび北アイルランド連合王国という言葉は本当に長い言葉</p>
<p>4. <code>word-break: break-word</code></p>
<p class="breakWord narrow">This is a long and
  Honorificabilitudinitatibus califragilisticexpialidocious Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu
 グレートブリテンおよび北アイルランド連合王国という言葉は本当に長い言葉</p>
					

CSS

.narrow {
  padding: 10px;
  border: 1px solid;
  width: 500px;
  margin: 0 auto;
  font-size: 20px;
  line-height: 1.5;
  letter-spacing: 1px;
}
.normal {
  word-break: normal;
}
.breakAll {
  word-break: break-all;
}
.keepAll {
  word-break: keep-all;
}
.breakWord {
  word-break: break-word;
}
					

规范

规范 状态 注释
CSS Text Module Level 3
The definition of 'word-break' in that specification.
工作草案 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
word-break Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 15 IE 完整支持 5.5 注意事项
完整支持 5.5 注意事项
注意事项 No version of Internet Explorer supports the initial 值。
完整支持 8 Prefixed 注意事项
Prefixed Implemented with the vendor prefix: -ms-
注意事项 不使用 -ms-word-break , which is a synonym for word-break .
Opera 完整支持 15 Safari 完整支持 3 WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 完整支持 15 Opera Android 完整支持 14 Safari iOS 完整支持 2 Samsung Internet Android 完整支持 1.0
break-word Chrome 完整支持 1 Edge 完整支持 79 Firefox 完整支持 67 IE 不支持 No Opera 完整支持 15 Safari 完整支持 3 WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 完整支持 67 Opera Android 完整支持 14 Safari iOS 完整支持 2 Samsung Internet Android 完整支持 1.0
keep-all Chrome 完整支持 44 Edge 完整支持 12 Firefox 完整支持 15 IE 完整支持 5.5 Opera 完整支持 31 Safari 完整支持 9 WebView Android 完整支持 44 Chrome Android 完整支持 44 Firefox Android 完整支持 15 Opera Android 完整支持 32 Safari iOS 完整支持 9 Samsung Internet Android 完整支持 4.0

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

见实现注意事项。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: