Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Typography

The text-wrap-style property

Reference for the CSS text-wrap-style property: choose how browsers pick line break points with auto, balance, stable, pretty or avoid-orphans, plus examples and support.

The text-wrap-style property chooses how the browser picks line breaks once wrapping is allowed. The default auto uses the fast, greedy algorithm: fill each line as far as it goes. The other values trade a bit of speed for nicer results in particular situations.

It is a longhand of text-wrap. In most code you will write text-wrap: balance rather than this property, but the longhand is handy when you want to change the style without touching the wrap mode.

CSS
h1 { text-wrap-style: balance; }

Try it

Auto, balance and pretty

The exact breaks depend on the font and browser, so your result may differ slightly. Where a browser does not support a value, that box simply looks like auto.

Syntax

CSS
text-wrap-style: auto | balance | stable | pretty | avoid-orphans
  • Initial value: auto
  • Applies to: block containers
  • Inherited: yes
  • Animatable: no
  • Computed value: as specified

Values

Value Description
auto Default greedy line breaking. Fast and predictable.
balance Makes lines of a short block about equal in length. Browsers limit this to a few lines, and longer blocks fall back to auto.
stable Lines before the text being edited keep their breaks as you type. Meant for editable regions such as text areas.
pretty Prefers better-looking breaks, such as avoiding a very short last line. The browser may spend more time on layout.
avoid-orphans A newer keyword that focuses on avoiding a short final line. Support is limited, so check a compatibility table.

Usage notes

  • Balance for headings. It shines on titles, captions, quotes and card text, where an uneven last line looks awkward.
  • Pretty for paragraphs. Apply pretty to long copy; its results are subtle, so you will mostly notice the absence of a one-word last line.
  • Layout does not change. The box keeps its width; only the break positions move. With balance, the text may look narrower than its container.
  • Performance. Prefer applying balance to headings rather than to entire pages, since larger blocks cost more to lay out.
  • Fallbacks are free. Browsers ignore keywords they do not know, so the worst case is ordinary wrapping.
  • Wrap mode matters. None of these styles do anything when text-wrap-mode is nowrap.

Browser support

balance is available in current versions of the major browsers. pretty and stable arrived later and are less uniform, and avoid-orphans is very new, so check a compatibility table.