Intent to Prototype: CSS headline balancing (`text-wrap: balance`)

1,641 views
Skip to first unread message

Koji Ishii

unread,
Feb 7, 2023, 7:31:20 AM2/7/23
to blink-dev

Contact emails

ko...@chromium.org

Explainer

None

Specification

https://w3c.github.io/csswg-drafts/css-text-4/#valdef-text-wrap-balance

Summary

Enables the lengths of lines in a paragraph balanced, for better readability and to prevent typographic widows. This feature is often used in headlines.



Blink component

Blink>Layout>Inline

Motivation



Initial public proposal



TAG review



TAG review status

Not applicable

Risks



Interoperability and Compatibility



Gecko: No signal

WebKit: No signal

Web developers: Positive (https://twitter.com/jensimmons/status/1542264788029423616)

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?



Debuggability



Is this feature fully tested by web-platform-tests?

Yes

Flag name



Requires code in //chrome?

False

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5196960707903488

This intent message was generated by Chrome Platform Status.

David Baron

unread,
Feb 8, 2023, 8:29:12 AM2/8/23
to Koji Ishii, blink-dev
On Tue, Feb 7, 2023 at 7:31 AM Koji Ishii <ko...@chromium.org> wrote:

Specification

https://w3c.github.io/csswg-drafts/css-text-4/#valdef-text-wrap-balance

Summary

Enables the lengths of lines in a paragraph balanced, for better readability and to prevent typographic widows. This feature is often used in headlines.



It's worth noting that the specification describes text-wrap as one of the longhand properties comprising part of the newly-shorthand white-space property.

Is what you're proposing to do here:

 (1) Implement:
       text-space-collapse: collapse | preserve | preserve-breaks
       text-wrap: wrap | no-wrap | balance
       and then turn white-space into a shorthand?  (Optionally, implement more of the values of text-space-collapse and/or text-wrap or also implement text-space-trim, but those don't seem necessary to do the text-wrap: balance feature in line with the spec's model.)  This seems to be the minimal approach that would be in line with the spec.

(2) Implement text-wrap balance without making it relate to the white-space property.  This would diverge from what is currently in the spec.

If you're planning to do (2), have you discussed it with the CSS Working Group?

-David

Koji Ishii

unread,
Feb 8, 2023, 11:19:25 PM2/8/23
to David Baron, blink-dev
Thanks for asking, David.

Right, the `white-space` property spec is in the middle of refactoring for years, so it's possible that it may have some risks. I'm still investigating multiple options for the style code, this is still prototyping, but I hope I can minimize the risk.
Reply all
Reply to author
Forward
0 new messages