8.1 · Typography & shape

Better line breaks: text-wrap

Balanced headings and paragraphs without orphaned words.

text-wrap: balance evens out the line lengths of short text like headings, so you don’t get one long line and one orphaned word. text-wrap: pretty is for paragraphs. It avoids a single short word on the last line, at a small cost in speed.

Both are hints. The browser decides the exact breaks, and browsers without support wrap normally.

Before
<h2>Five things nobody tells you
about moving&nbsp;abroad</h2>
<!-- manual <br> and &nbsp; that break
     at every other width -->
Now
h1, h2, h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}