CSS text-wrap: balance eliminates orphaned words in headlines natively
Frontend developers have long struggled with orphaned words in headings, where a single word wraps alone onto a new line at certain viewport widths. The CSS property text-wrap: balance offers a native browser-level fix by distributing text as evenly as possible across all lines without requiring manual edits or JavaScript. A companion property, text-wrap: pretty, addresses the same orphan problem in body text by applying a lookahead only on the final few lines, leaving the rest of the paragraph unchanged. Together, both properties replace older workarounds such as non-breaking spaces, soft hyphens, max-width tweaks, and JavaScript rebalancing libraries. The balance property is intentionally limited to roughly six lines of content to keep the underlying algorithm computationally efficient, making it best suited for headlines and pull quotes.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in