CSS Reference ยท Typography
The text-wrap-mode property
Reference for the CSS text-wrap-mode property: turn automatic line wrapping on with wrap or off with nowrap, how it relates to white-space and text-wrap, with live examples.
The text-wrap-mode property switches automatic line wrapping on or off. With wrap (the default), a line breaks when the next word does not fit. With nowrap, the line never breaks at soft wrap points, so long text runs past the edge of its box.
It is one of the two longhands of text-wrap and one of the two longhands of white-space. It does not touch how spaces and line breaks in the source are collapsed; that is the job of white-space-collapse.
.price { text-wrap-mode: nowrap; }
Try it
The second box clips because it also has overflow: hidden. Without it, the text would spill out to the right.
Syntax
text-wrap-mode: wrap | nowrap
- Initial value:
wrap - Applies to: text and the elements that contain it
- Inherited: yes
- Animatable: no
- Computed value: as specified
Values
| Value | Description |
|---|---|
wrap |
Text wraps at allowed break opportunities when it reaches the end of the line. |
nowrap |
Text does not wrap at soft wrap opportunities. Forced breaks (a <br> element, or a preserved newline) still break the line. |
Usage notes
- Inheritance. The value inherits, so setting
nowrapon a container affects all text inside, unless a child setswrapagain. - Overflow follows. With
nowrap, content wider than its box overflows. Pair it withoverflowandtext-overflowto truncate, or let the user scroll. - Relationship to
white-space.white-space: nowrapsets this property tonowrapandwhite-space-collapsetocollapse. Writingtext-wrap-mode: nowrapalone changes only the wrapping and keeps preserved whitespace intact, which is useful withpre-like blocks. - Cascade order.
text-wrap,white-spaceandtext-wrap-modecan all set the same value, so the later declaration wins. - Small UI pieces. Prices, badges, button labels and table headers are common targets, but very long
nowraptext can break layouts on narrow screens. Test on a small viewport. - Accessibility. Text that cannot wrap can force horizontal scrolling at high zoom levels. Avoid
nowrapon long running text.
Browser support
A recent split of white-space into longhands, so older browsers only understand the white-space and text-wrap forms. Check a compatibility table before using the standalone property without a fallback.
Related
text-wrapโ shorthand withtext-wrap-styletext-wrap-styleโ balance, pretty, stablewhite-spaceโ the older shorthandwhite-space-collapseโ whitespace collapsing- Lesson: Wrapping, Overflow and Hyphens