Skip to content
Tutorials Center
My learning

Topics

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.

CSS
.price { text-wrap-mode: nowrap; }

Try it

Wrap versus nowrap

The second box clips because it also has overflow: hidden. Without it, the text would spill out to the right.

Syntax

CSS
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 nowrap on a container affects all text inside, unless a child sets wrap again.
  • Overflow follows. With nowrap, content wider than its box overflows. Pair it with overflow and text-overflow to truncate, or let the user scroll.
  • Relationship to white-space. white-space: nowrap sets this property to nowrap and white-space-collapse to collapse. Writing text-wrap-mode: nowrap alone changes only the wrapping and keeps preserved whitespace intact, which is useful with pre-like blocks.
  • Cascade order. text-wrap, white-space and text-wrap-mode can 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 nowrap text 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 nowrap on 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.