Naar hoofdinhoud
← 🎨 CSS as a design systemΒ·Module B4 Β· Les 6
OpdrachtApply text-wrap: balance to h1 and h2. Apply text-wrap: pretty to p.

tekstomloop: balans / mooi (de game-changers van 2024)

100 XP6 min
Theorie

Two values that solve old typography pain

h1, h2 { text-wrap: balance; }     /* headings: distribute words evenly across lines */
p      { text-wrap: pretty; }      /* body: prevent orphans (single-word last lines) */

text-wrap: balance

Shipped Chrome/Safari/FF 2023-24. For HEADINGS β€” distributes words so each line has roughly the same width.

Before:

This is a long heading that breaks
poorly

After text-wrap: balance:

This is a long heading
that breaks poorly

Symmetric. Looks designed. Free.

text-wrap: pretty

Shipped 2024. For BODY text β€” prevents the last line of a paragraph from being a single short word ("orphan"). Slightly more expensive than auto so don't apply to all text β€” just paragraphs where it matters.

… some long paragraph that ends with a
single

After text-wrap: pretty:

… some long paragraph that ends with
a single

The browser shifts a word from the previous line.

When NOT to use them

  • On dynamic content that re-renders frequently β€” balance is computed lazily and can cause jank.
  • On very long paragraphs β€” pretty slows down with O(linesΒ²) work in extreme cases.

For 99% of marketing sites with reasonable content, both are free wins.

Browser support

  • Chrome / Edge β€” both shipped.
  • Safari β€” balance shipped, pretty mostly.
  • Firefox β€” both shipped.

In 2026: ship both, treat as a progressive enhancement (old browsers fall back to normal wrap, no harm done).

πŸ”’

Registreer om te beginnen met coderen

Theorie is voor iedereen. De editor, live preview en check ontgrendelen met een 7-daagse gratis proefperiode β€” kaart vereist, opzegbaar.

Registreren β€” gratis proef β†’

De eerste 10 lessen in elke track zijn gratis. Geen kaart nodig.

← VorigeVolgende les β†’

EΓ©n Python- of web-tip per dag β€” per e-mail

Kort, met de hand geschreven, geen spam. Met één klik afmelden.