word-wrap u2z6l
The word-wrap property is used to specify whether lines can break inside words that are so long that they would overflow their container and that are otherwise not breakable by default. 505w3u
How is it different from the word-break
property breaks a line in between two characters of a word which comes at the end of this line, to make the whole line fit inside its container. But the word-wrap
property, on the other hand, breaks a word when the word itself takes up an entire line and overflows that line; that is, when the word itself and on its own is too long that it would overflow its container, so we make it wrap just line a line would wrap to fit inside its container.
The word-wrap
property only has an effect when white-space
allows wrapping.
The word-wrap
property is called overflow-wrap
in the CSS Text Level 3 specification (which is still a Working Draft so things may change).
The two properties (word-break
property breaks all words at the end of a line, even those that would normally wrap onto another line and wouldn’t overflow their container.
No hyphenation character is inserted at the break point of the word. Because of that, it would be wiser to use this property in conjunction with the hyphens
property.
Official Syntax 55184y
- Syntax:
word-wrap: normal | break-word
- Initial: normal
- Applies To: all elements
- Animatable: no
Values 584j31
- normal
- lines may only break at normal word break points.
- break-word
- normally unbreakable words may be broken at arbitrary points if there are no otherwise acceptable break points in the line.
Examples 3e5p5z
The following line will break all words (inside paragraphs) that are too long and would normally overflow their container.
p { word-wrap: break-word; }
Live Demo 2x4j2k
View this demo on the Codrops PlaygroundBrowser k5t66
CSS3 Overflow-wrap 3m5q1r
Allows lines to be broken within words if an otherwise unbreakable string is too long to fit. Currently mostly ed using the `word-wrap` property.
W3C Working Draft
ed from the following versions:
Desktop 3n671n
- 23
- 49
- 5.5
- 12
- 6.1
Mobile / Tablet 4q224p
- 7.0
- 4.4
- all
- 66
- 60