# text-wrap

> The `text-wrap` CSS property controls how text inside an element is wrapped.

## How do I balance heading text lines in CSS?

The property that controls how lines of text break. The 'balance' value evens out line lengths in headings, 'nowrap' prevents wrapping, and 'wrap' is the default behavior. A shorthand for `text-wrap-mode` and `text-wrap-style`.

- Topic: Text Handling
- Type: property
- Browser support: Chrome 114+, Chrome Android 114+, Edge 114+, Firefox 121+, Firefox Android 121+, Safari 17.4+, Safari iOS 17.4+

## Example

Wrong:

```css
h1 {
  text-wrap: balance;
}
p {
  text-wrap: balance;
}
```

Right:

```css
h1 {
  text-wrap: balance;
}
p {
  text-wrap: pretty;
}
```

'balance' is meant for short blocks like headings, while 'pretty' avoids a lone last word in paragraphs.

## Common mistakes

- Expecting 'balance' to work on long paragraphs; browsers only balance a few lines.

## Key points

- Headings use 'balance' instead of manual `<br>` tags.
- Body text uses 'pretty' to avoid a single word on the last line.
- 'balance' is kept for short blocks, since browsers skip it on long text.

## Interview questions

### What is the difference between text-wrap balance and pretty?

'balance' evens out the length of all lines in a short block. 'pretty' keeps normal wrapping but avoids very short last lines.

### Is text-wrap: nowrap the same as white-space: nowrap?

It has the same wrapping effect. `text-wrap: nowrap` sets only `text-wrap-mode`, while `white-space` also sets how spaces collapse.

### Why does text-wrap: balance not work on my paragraph?

Browsers limit balancing to a small number of lines for performance, so long paragraphs keep normal wrapping.

## Related cards

- [white-space](https://wonderium.dev/css/white-space.md)
- [white-space-collapse](https://wonderium.dev/css/white-space-collapse.md)
- [hyphens](https://wonderium.dev/css/hyphens.md)
- [`<h1>...<h6>`](https://wonderium.dev/html/h1-h6.md)
- [overflow-wrap](https://wonderium.dev/css/overflow-wrap.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/text-wrap
- Last updated: 2026-11-25
