Skip to content

The definition of text-wrap:balance is overprescriptive #9111

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

Open
litherum opened this issue Jul 25, 2023 · 4 comments
Open

The definition of text-wrap:balance is overprescriptive #9111

litherum opened this issue Jul 25, 2023 · 4 comments

Comments

@litherum
Copy link
Contributor

litherum commented Jul 25, 2023

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

Line boxes are balanced when the standard deviation from the average inline-size of the remaining space in each line box is reduced over the block

I'm specifically concerned about defining balancing using a rigorous definition of "standard deviation ... of the remaining space."

This is one particular definition of balanced, but there are quite a few different definitions that could be used with different tradeoffs. In particular, implementations will likely use a fast approximation of balancing, and won't actually use this specific mathematic formula from the spec. The spec should be relaxed to not prescribe any mathematically precise definition of "balanced."

@frivoal
Copy link
Collaborator

frivoal commented Jul 25, 2023

@litherum would something like this work for you?

Line boxes are balanced when the variation in line length (including lines that end in a forced break) is minimized over the block.

The exact algorithm is UA-defined.

This would gain flexibility, potentially at the expense of some small reduction in interop. But that doesn't see overly important, as relying on an exact choice of line-breaking is already fragile for many other reasons.

@nigelmegitt
Copy link

See also #8640 (comment) in which I argue that text-wrap: balance based on line length alone is not an appropriate solution for breaking 2 or 3 line blocks of subtitle/caption text into lines: grammatical constructions need to be taken into account as well.

@fantasai
Copy link
Collaborator

@frivoal I don't think that fix quite addresses the issue, and also the reason the spec focuses on the remaining space on the line is because addressing the line length itself doesn't work in the presence of floats.

@frivoal
Copy link
Collaborator

frivoal commented May 29, 2024

Should we simply replace "standard deviation" with "variation" in the original phrasing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants