Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

[css-overflow] [css-text] Interaction between whitespace collapsing and line-clamp #12008

Closed

Description

@andreubotella

The current spec text for block-ellipsis (which is one of the longhands for line-clamp) says that when an ellipsis is inserted on the last line before clamp, it must be placed after the last soft wrap opportunity that would make the line with the ellipsis not overflow, considering that the content after the ellipsis gets pushed to the next line box or fragment.

However, according to the Unicode line breaking algorithm, ASCII spaces don't have a break opportunity before them, but only after them. Which means any soft wrap opportunity caused by a space would show the ellipsis after the space, not at the end of the word. Or at least that would be the case if the ellipsis inline is added at the end of the line box during line breaking and before phase II of whitespace processing.

There's also the fact that the block-ellipsis spec text allows inserting the ellipsis in the middle of text-wrap: nowrap text, since it only talks about finding the last soft wrap opportunity, and nowrap does not remove wrap opportunities, it just prevents wrapping. Given that, the question comes up of how trailing whitespace would work before the ellipsis inside white-space: pre text. If we just say to collapse as usual according to phase II, and then add the ellipsis, we would still have spaces between the end of the word and the ellipsis in white-space: pre text. Do we want that?

Activity

  1. andreubotella commented on Mar 26, 2025

    @andreubotella
    MemberAuthor
  2. frivoal commented on Jun 6, 2025

    @frivoal
    Collaborator

    Interesting. I think there's several parts in there.

    For « nowrap does not remove wrap opportunities, it just prevents wrapping » I suspect that can be changed, and have the definition of text-wrap-mode: nowrap say that it suppresses opportunities. In that case, yes, if the whole line (or the whole block) is set to nowrap, then that means you cannot insert the ellipsis in the middle of the line, and you either have to tack it at the very end—including after preserved spaces if any—if there's room, or have to remove the whole line to make room if there isn't, but that seems appropriate: if the content is indivisible, it is indivisible.

    In terms of wrap opportunities being after, not before, spaces. I agree that we don't want the ellipsis being after a space that would otherwise be removed by phase two, so we need to do ellipsis insertion after phase two.

    I think the case where I'm least comfortable is when the line ends with preserved white-space (which is thus not discarded) which hang (as can happen with white-space: pre-wrap). This is different from the nowrap case: here, we can wrap, but we did ask for preserving. In that case, what would fall out of the above is that the ellipsis would be inserted after the space, even though the line is wrapable. This may also be the desirable behavior (the author did ask for spaces to be preserved after all), but I'm less sure.

  3. andreubotella commented on Jun 6, 2025

    @andreubotella
    MemberAuthor

    For « nowrap does not remove wrap opportunities, it just prevents wrapping » I suspect that can be changed, and have the definition of text-wrap-mode: nowrap say that it suppresses opportunities. In that case, yes, if the whole line (or the whole block) is set to nowrap, then that means you cannot insert the ellipsis in the middle of the line, and you either have to tack it at the very end—including after preserved spaces if any—if there's room, or have to remove the whole line to make room if there isn't, but that seems appropriate: if the content is indivisible, it is indivisible.

    We can probably say "soft wrap opportunities were breaking would be allowed (i.e. not text-wrap: nowrap)" without needing to change css-text.

    I think the case where I'm least comfortable is when the line ends with preserved white-space (which is thus not discarded) which hang (as can happen with white-space: pre-wrap). This is different from the nowrap case: here, we can wrap, but we did ask for preserving. In that case, what would fall out of the above is that the ellipsis would be inserted after the space, even though the line is wrapable. This may also be the desirable behavior (the author did ask for spaces to be preserved after all), but I'm less sure.

    Although I believe the goal is for browsers to implement hanging punctuation eventually, I'm not sure how possible this currently is in Chromium. Maybe it would be doable for line-clamp ellipsis, due to the special way in which we're implementing them, but wouldn't be for other punctuation. But I would need to look into it.

  4. 24 remaining items

  5. andreubotella commented on Oct 1, 2025

    @andreubotella
    MemberAuthor

    web-platform-tests/wpt#55181 adds one more test, and fixes two existing tests that don't work with either this issue or #12811.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed Accepted by CSSWG ResolutionChanges backed by a CSSWG resolution.TestedMemory aid - issue has WPT testscss-overflow-4css-text-3Current Worktopic: line-clampline-clamp, -webkit-line-clamp, and related long hands, not including continue:discard

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions