← Back to release summary

CSS text-wrap: pretty

Category
CSS
Type
Chromium catches up
Status
Enabled by default (Chrome 117)
Intent stage
Start prototyping

WPT details: The following tests cover the CSS parser: https://wpt.fyi/results/css/css-text/parsing?label=master&label=experimental&aligned&q=text-wrap The precise line breaking algorithm is UA defined, so it is not testable by wpt, instead, tests are in wpt_internal.

Summary

Adjusts line breaking to avoid a short single word on the last line (also known as typographic orphans.) When `text-wrap: pretty` is specified, paragraphs that will end up with a short single word on the last line are adjusted so that the last line has two or more words. It also adjusts hyphenation if consecutive hyphenated lines appear at the end of a paragraph. The algorithm is based on the Knuth-Plass algorithm, as used by TeX. It computes scores for all candidates, and chooses the best one. To balance between the typographic benefits and the performance impacts, it adjsuts the last 4 lines of paragraphs that meet certain conditions.

Standards & signals

Ecosystem

Docs: https://docs.google.com/document/d/1jJFD8nAUuiUX6ArFZQqQo8yTsvg8IuAq7oFrNQxPeqI/edit?usp=sharing

Samples: https://output.jsbin.com/hopejeb

View on chromestatus.com