You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-text-4 / css-overflow-4] Interaction of text-wrap: balance and (-webkit-)line-clamp #9310
It would be good to clarify how text-wrap: balance interacts with line-clamp.
Specifically, when both balancing and clamping are requested, in which order do these effects operate? Does the block first have its lines wrapped using the balance algorithm, and then clamping applied to the resulting lines (without affecting how they wrap), or is clamping applied first and then balancing applied only to the lines up to the clamp limit?
Or in simpler terms, is it expected that (-webkit-)line-clamp may change the line-breaks used in a block?
It seems most intuitive to me that line-clamp applies after the line-breaks for a block have been determined, as it is defined in terms of lines. But the test at https://wpt.live/css/css-text/white-space/text-wrap-balance-line-clamp-001.html appears to assume that text-wrap: balance will be applied only to the lines up to the -webkit-line-clamp limit.
This codepen has an example where this effect is visible. In current Chrome Canary, varying the line-clamp limit results in changes to the line-breaking throughout the paragraph. Is this the expected/desired behavior, or should it be considered a bug?
Depending on the answer to this, the text-wrap-balance-line-clamp-001.html test may need revision.
It seems most intuitive to me that line-clamp applies after the line-breaks for a block have been determined
FWIW we (Blink) previously had this behaviour - but after web-developers tested this interaction they were confused believing that text-wrap: balance was broken for this case.
Based on this feedback we changed it to only balance the lines within the line-clamp range. We haven't received any bug reports since for this interaction.
Thanks for the comment, Ian, that's interesting. I'm curious if people considered the implications of this for dynamically-varying line-clamp, or looked only at static examples?
In the purely static case, balancing only the displayed lines makes good sense, but I find the dynamic behavior where changing the line-clamp value causes line-wrapping to change to be a bit disconcerting. Interested to hear what other people think...?
I'm curious if people considered the implications of this for dynamically-varying line-clamp, or looked only at static examples?
From examples I've seen - most folks have a non-dynamic line-clamp (super rare to animate this). If it does change (say based on viewport/container width, etc) I suspect most web developers would still expect it to balance the visible lines.
(FWIW we received this feedback from more that one set of developers trying the API - e.g. wasn't a single voice).
Activity
bfgeek commentedon Sep 6, 2023
FWIW we (Blink) previously had this behaviour - but after web-developers tested this interaction they were confused believing that
text-wrap: balancewas broken for this case.Based on this feedback we changed it to only balance the lines within the line-clamp range. We haven't received any bug reports since for this interaction.
cc/ @kojiishi
jfkthame commentedon Sep 8, 2023
Thanks for the comment, Ian, that's interesting. I'm curious if people considered the implications of this for dynamically-varying line-clamp, or looked only at static examples?
In the purely static case, balancing only the displayed lines makes good sense, but I find the dynamic behavior where changing the line-clamp value causes line-wrapping to change to be a bit disconcerting. Interested to hear what other people think...?
bfgeek commentedon Sep 8, 2023
From examples I've seen - most folks have a non-dynamic line-clamp (super rare to animate this). If it does change (say based on viewport/container width, etc) I suspect most web developers would still expect it to balance the visible lines.
(FWIW we received this feedback from more that one set of developers trying the API - e.g. wasn't a single voice).
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
35 remaining items
[css-text-4] Clamp then balance
frivoal commentedon May 29, 2024
Fixed by 32dee03
Cherry-pick c1353df. rdar://123854267
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…
Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r…
Bug 1731541 - When line-clamp is in effect, make text-wrap:balance co…