Justifying Text-Wrap: Pretty
5 days ago
- #typography
- #Safari
- #web-development
- Safari introduced a reasonable implementation of `text-wrap: pretty` in 2025, improving web typography.
- Historically, browsers used a naive greedy algorithm for line breaking, leading to less attractive text layouts.
- The Knuth-Plass algorithm, developed in 1981, optimized line breaking for print, but web browsers faced additional challenges due to dynamic window sizes.
- `text-wrap: pretty` aims to balance line lengths, while `text-align: justify` adjusts whitespace for exact alignment.
- Combining `text-wrap: pretty` with `text-align: justify` in Safari can result in excessive whitespace between words.
- The issue arises because the dynamic programming approach slightly undershoots the target width to balance line lengths, which becomes noticeable when justifying text.
- The article calls for a fix to this issue to achieve the intended typographic beauty on the web.