← Back to CSS
23

Text wrap: adaptive typography with cleaner line breaks

Avoid awkward title wraps and lonely last words by using `text-wrap` to improve readability and visual balance.

📘 Theory

`text-wrap: balance`

Best for short text where visual rhythm matters.

1

When you apply `text-wrap: balance`, the browser tries to distribute the text so each line feels more even in length.

2

That makes it especially useful for headings, pull quotes, banners and other short blocks where one weak last line would disrupt the composition.

3

Browsers usually limit balancing to a relatively small number of lines for performance reasons, so it is not meant to rebalance huge blocks of copy.

`text-wrap: pretty`

A gentler fix for longer reading text.

1

Unlike `balance`, which tries to improve the overall line distribution, `pretty` pays special attention to the final line and tries to avoid stranded single words.

2

That makes it a practical fit for paragraphs, article intros and body copy where readability matters more than perfect geometric symmetry.

Performance considerations

Better line breaks still have a layout cost.

1

Every time the browser recalculates layout, these smarter wrapping strategies may need to run again, especially when the viewport changes.

2

Use `balance` for short blocks where the payoff is obvious, and reserve `pretty` for text that truly benefits from a cleaner ending line.

🧪 Learn by doing

Example Lab: balance vs pretty Resize the container and compare the default wrap against `balance` and `pretty`.
Example Challenge: improve the hero title Apply the right property so the hero heading keeps more balanced lines at different widths.

🧰 Resources

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com