The overflow-wrap CSS property sets whether the browser should insert line breaks within words to prevent text from overflowing its content box.
Note: In contrast to word-break, overflow-wrap will only create a break if an entire word cannot be placed on its own line without overflowing.
The property was originally a nonstandard and unprefixed Microsoft extension called word-wrap, and was implemented by most browsers with the same name. It has since been renamed to overflow-wrap, with word-wrap being an alias.
/* Keyword values */ overflow-wrap: normal; overflow-wrap: break-word; /* Global values */ overflow-wrap: inherit; overflow-wrap: initial; overflow-wrap: unset;
The overflow-wrap property is specified as a single keyword chosen from the list of values below.
normalbreak-wordnormal | break-word
This example compares the results of overflow-wrap, word-break, and hyphens when breaking up a long word.
<p class="normal">They say the fishing is excellent at Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, though I've never been there myself. (<code>normal</code>)</p> <p class="overflow-wrap">They say the fishing is excellent at Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, though I've never been there myself. (<code>overflow-wrap</code>)</p> <p class="word-break">They say the fishing is excellent at Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, though I've never been there myself. (<code>word-break</code>)</p> <p class="hyphens">They say the fishing is excellent at Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, though I've never been there myself. (<code>hyphens</code>, without <code>lang</code> attribute)</p> <p class="hyphens" lang="en">They say the fishing is excellent at Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, though I've never been there myself. (<code>hyphens</code>, English rules)</p> <p class="hyphens" lang="de">They say the fishing is excellent at Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, though I've never been there myself. (<code>hyphens</code>, German rules)</p>
p {
width: 13em;
background: gold;
}
.overflow-wrap {
overflow-wrap: break-word;
}
.word-break {
word-break: break-all;
}
.hyphens {
hyphens: auto;
}
| Specification | Status | Comment |
|---|---|---|
| CSS Text Module Level 3 The definition of 'overflow-wrap' in that specification. | Working Draft | Initial definition |
| Initial value | normal |
|---|---|
| Applies to | all elements |
| Inherited | yes |
| Media | visual |
| Computed value | as specified |
| Animation type | discrete |
| Canonical order | the unique non-ambiguous order defined by the formal grammar |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | Yes
|
18
|
49
|
5.5
|
Yes
|
Yes
|
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes
|
? | Yes
|
49
|
Yes | Yes
|
? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/word-wrap