Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-wrap: balance #561

Closed
3 tasks done
foolip opened this issue Oct 6, 2023 · 10 comments
Closed
3 tasks done

text-wrap: balance #561

foolip opened this issue Oct 6, 2023 · 10 comments
Labels
focus-area-proposal Focus Area Proposal

Comments

@foolip
Copy link
Member

foolip commented Oct 6, 2023

Description

text-wrap: balance adjusts line breaking to balance the lengths of lines in a paragraph, for better readability and to prevent typographic widows. This feature is often used in headlines. It is also called headline balancing.

WebVTT also uses text-wrap: balance.

Specification

https://drafts.csswg.org/css-text-4/#valdef-text-wrap-style-balance

Open Issues

https://github.com/w3c/csswg-drafts/issues?q=is%3Aissue+is%3Aopen+text-wrap+balance

Tests

https://wpt.fyi/results/css/css-text/white-space?label=master&label=experimental&aligned&q=balance
https://wpt.fyi/results/css/css-text/parsing/text-wrap-valid.html?label=master&label=experimental&aligned

Current Implementations

  • Blink
  • Gecko
  • WebKit

Standards Positions

mozilla/standards-positions#755
WebKit/standards-positions#143

Browser bug reports

https://bugzilla.mozilla.org/show_bug.cgi?id=1731541
https://bugs.webkit.org/show_bug.cgi?id=249840

Developer discussions

https://clagnut.com/blog/2424
https://medium.com/swlh/typographic-orphans-on-the-web-266e32f756fe

Polls & Surveys

https://2023.stateofcss.com/en-US/features/typography/#text_wrap_balance

There are 20 freeform comments here, for example "Waiting for support to be above 90%, very cool feature"

It's also in the "Other Answers" section of https://2023.stateofcss.com/en-US/usage/#css_interoperability_features. Note also Devographics/Monorepo#324 if comparing the number of "Other Answers" to the main view.

Existing Usage

https://chromestatus.com/metrics/feature/timeline/popularity/4544

Workarounds

No response

Accessibility Impact

No response

Privacy Impact

No response

Other

Blink's Intent to Ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/f5eLz6PIXaI/m/R__N3BdjAAAJ

https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=12038 is a quick test of support. Resize the window until the line breaks and see where the line break happens.

Although the implementation bugs for Gecko and WebKit are closed, I wasn't able to make this test work. It looks like in Safari Technology Preview it's behind a "CSS text-wrap: balance stable pretty" flag which is disabled by default. For Firefox, I couldn't find anything in about:config.

@foolip foolip added the focus-area-proposal Focus Area Proposal label Oct 6, 2023
@nt1m
Copy link
Member

nt1m commented Oct 7, 2023

I would be interested in seeing interop regarding the related longhand properties (white-space-collapse, white-space, text-wrap-style/mode). Chrome currently implements an old version of the properties.

@foolip
Copy link
Member Author

foolip commented Oct 24, 2023

@nt1m do you know if there are tests for those longhand properties?

@nt1m
Copy link
Member

nt1m commented Oct 24, 2023

@nt1m do you know if there are tests for those longhand properties?

Yes I updated them recently: https://wpt.fyi/results/css/css-text/parsing?label=master&label=experimental&aligned&q=text-wrap

@nt1m
Copy link
Member

nt1m commented Oct 24, 2023

Hmm, there are none testing specifically text-wrap-mode / text-wrap-style but they could be added pretty easily. Only tests for the shorthand right now.

@kojiishi
Copy link

I would be interested in seeing interop regarding the related longhand properties (white-space-collapse, white-space, text-wrap-style/mode). Chrome currently implements an old version of the properties.

Blink shipped white-space-collapse and shorthadified white-space. Shorthandifying white-space required a number of sites to change, so I hope sites are ready by now. We're aware of the recent spec change for text-wrap after we shipped it. We're happy to match what other implementations ship.

It looks like Gecko is going to ship text-wrap: balance as a longhand in its initial release, and then shorthandify it in future. @jfkthame
https://groups.google.com/a/mozilla.org/g/dev-platform/c/uAscf5sfEdc/m/0EQcFYqxAAAJ

@nt1m
Copy link
Member

nt1m commented Nov 16, 2023

It would be good to exclude interaction with floats / line-clamp from the focus area.

@foolip
Copy link
Member Author

foolip commented Nov 20, 2023

@nt1m does that mean the test with "float" or "line-clamp" in their names in https://wpt.fyi/results/css/css-text/white-space?label=master&label=experimental&aligned&q=balance?

@nt1m
Copy link
Member

nt1m commented Nov 20, 2023

Yes. I think it's more important that all browsers get the shorthands / longhands right: https://wpt.fyi/results/css/css-text/parsing?label=master&label=experimental&aligned&q=text-wrap

Otherwise, it will lead to web compat issues in the future, especially with Chrome supporting white-space: balance which is no longer the latest spec.

@jgraham
Copy link
Contributor

jgraham commented Feb 1, 2024

This proposal has been accepted as part of Interop 2024! On behalf of the entire Interop team, thank you for proposing it. You’ll be able to track progress on this topic throughout the year via the Interop 2024 dashboard.

@jgraham jgraham closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus-area-proposal Focus Area Proposal
Projects
Status: Done
Development

No branches or pull requests

5 participants