Skip to content

-webkit-line-clamp #16

Closed
Closed

Description

@bfgeek

Description
-webkit-line-clamp is a highly used feature to clamp the number of lines shown for inline-content.

Specification
https://drafts.csswg.org/css-overflow-3/#propdef--webkit-line-clamp

Tests
https://wpt.fyi/results/css/css-overflow?label=master&label=experimental&aligned&q=webkit-line-clamp
... kinda - some of these tests are incorrect.

Rationale
The un-prefixed version "line-clamp" is relatively expensive for engines to implemented. (Specifically dropping content after the trimmed line is difficult for /reasons/).

However that shouldn't stop getting the behaviour of -webkit-line-clamp closer to line-clamp.

There are roughly three areas for improvement across browsers.

  1. RTL support. We (Blink) added this in 2020[1] and is the biggest show-stopper for people using this feature from us talking with various web developers.

  2. Create a block-flow box, instead of a flex box. We (Blink) also fixed this in 2020 - under the hood Blink creates a block-flow box instead of a flex box. This means that it mirrors the spec more closely (making far more likely we can directly map it onto the un-prefixed version) and also matches what developers expect. See:

  3. Support "-webkit-line-clamp: none" only FF supports this currently, and this would round out making it a minimal when un-prefixing.

cc/ @frivoal

[1] https://groups.google.com/a/chromium.org/g/blink-dev/c/SVD5wSqVwKU/m/eY28UiNkAwAJ?pli=1

Activity

  1. foolip commented on Nov 11, 2021

    @foolip
    Member

    Thanks for submitting this proposal, @bfgeek! Regarding -webkit-line-clamp: none, do you know if there are Chromium or WebKit bugs for that? I couldn't find either in a quick search, at least.

  2. foolip commented on Nov 11, 2021

    @foolip
    Member

    Survey data supporting this is in #7. Most of the responses just said "line-clamp", but these were a bit more elaborate:

    • "line-clamp with children elements"
    • "I like how line-clamp is implemented in Chrome. The rest is just a bad developer experience and requires additional JavaScript."
    • "-webkit-line-clamp is another one that would be good to have standardised."
    • "not full support of line-clamp for safari - lists with line clamp"
  3. jgraham commented on Nov 11, 2021

    @jgraham
    Contributor

    some of these tests are incorrect

    It would be good to get some more detail on which tests are incorrect/missing here.

    Also, if I understand correctly it also seems like there's some spec work needed? Although there's definitely a good case that authors are looking for improvements here, we don't want to include things that are likely to undergo significant churn. How confident are we that we will have an correct set of tests and an accurate/agreed-upon spec before the new year?

  4. bfgeek commented on Nov 11, 2021

    @bfgeek
    Author

    Thanks for submitting this proposal, @bfgeek! Regarding -webkit-line-clamp: none, do you know if there are Chromium or WebKit bugs for that? I couldn't find either in a quick search, at least.

    We don't have an explicit bug for this. This was implemented in FF when they shipped -webkit-line-clamp, and is the main reason why Blink fails the various tests linked above.

    It would be good to get some more detail on which tests are incorrect/missing here.

    https://groups.google.com/a/chromium.org/g/blink-dev/c/SVD5wSqVwKU/m/eY28UiNkAwAJ?pli=1
    external/wpt/css/css-overflow/webkit-line-clamp-008.html
    external/wpt/css/css-overflow/webkit-line-clamp-029.html

    Are the two tests. These test the bad "line-clamp each child box individually" which nobody we've talked to wants.

    Also, if I understand correctly it also seems like there's some spec work needed? Although there's definitely a good case that authors are looking for improvements here, we don't want to include things that are likely to undergo significant churn. How confident are we that we will have an correct set of tests and an accurate/agreed-upon spec before the new year?

    There isn't really any spec work here. (Aside from any potential clarifications). The spec is currently aspirational, in that it requires dropping children after when the line-clamp is applied. This is currently very difficult for browsers, but importantly isn't the source of the developer pain here.

    We (Blink) believe that with our current behaviour we'll be able to completely transition to the un-prefixed version without any compat issues. However (again) the dropping content issue isn't the source of developer pain. Its the other interop issues.

    Survey data supporting this is in #7. Most of the responses just said "line-clamp", but these were a bit more elaborate:

    This is great! At least two (three?) of these responses are happy with the better behaviour:

    "I like how line-clamp is implemented in Chrome. The rest is just a bad developer experience and requires additional JavaScript."
    "line-clamp with children elements"
    "not full support of line-clamp for safari - lists with line clamp"

    (for the list one I didn't even realize that we (Blink) supported this, but it makes sense: https://www.software.hixie.ch/utilities/js/live-dom-viewer/?saved=9796 )

  5. jgraham commented on Nov 11, 2021

    @jgraham
    Contributor

    There isn't really any spec work here. (Aside from any potential clarifications). The spec is currently aspirational, in that it requires dropping children after when the line-clamp is applied. This is currently very difficult for browsers, but importantly isn't the source of the developer pain here.

    OK, that sounds good. Is it accurate to say the proposal is "pass the existing tests from https://wpt.fyi/results/css/css-overflow?label=master&label=experimental&aligned&q=webkit-line-clamp, with -008 and -029 changed to match the current Blink behaviour"?

  6. bfgeek commented on Nov 11, 2021

    @bfgeek
    Author

    OK, that sounds good. Is it accurate to say the proposal is "pass the existing tests from https://wpt.fyi/results/css/css-overflow?label=master&label=experimental&aligned&q=webkit-line-clamp, with -008 and -029 changed to match the current Blink behaviour"?

    Thats correct.

  7. bfgeek commented on Nov 11, 2021

    @bfgeek
    Author

    (at least I believe those are the only two tests which need to be updated from my previous analysis).

  8. bfgeek commented on Nov 11, 2021

    @bfgeek
    Author
  9. added
    requires:spec
    on Nov 18, 2021
  10. foolip commented on Nov 23, 2021

    @foolip
    Member

    @bfgeek I added the requires:spec label here in our previous meeting, but I hadn't read #16 (comment) then, just noted the "kinda" in the description.

    For the spec situation, can you outline which bits of the spec that are included, or which should be ignored, whichever is the smaller set?

    Or could this be framed as following the spec, but the tests we include don't exercise some of the things that we want to leave out of scope?

  11. mrego commented on Nov 23, 2021

    @mrego
    Member

    From the spec side, @frivoal has been paying attention to this topic, and maybe he can help to clarify the status of things.

  12. frivoal commented on Nov 26, 2021

    @frivoal

    The spec's status is about as stable as it'll get without implementations progressing further.
    With a couple of minor exceptions (see below), it's meant to be design-complete, both taking into account what the "right" design should be, and compat constraint as they are understood.

    If implementation experience shows that we underestimated the demands of compatibility with the -webkit- version, then we may have to tweak things a bit, but otherwise it should be good to go. If there are questions as to why the design is the way it is, I'm happy to go into that, but for now, I think it's enough to say the design is intentional, not pending any particular rework by the CSSWG, and complete except for implementation feedback and a couple of comparatively small issues.

    The remaining two issues are w3c/csswg-drafts#2970 and w3c/csswg-drafts#2971. Happy to go into those too, but I don't think it should have a strong bearing on this discussion.

  13. bfgeek commented on Nov 29, 2021

    @bfgeek
    Author

    Right the spec is effectively fine at the moment. Those final issues are important once implementations can support dropping the content after the ellipsis. (Which no implementations can currently support this easily).

    Since implementations aren't currently able to support dropping the content after the ellipsis (there isn't anything fundementally bad here, its just a lot of work to do correctly) - the focus of this issue would be getting implementations to be interoperable on everything except for dropping content.

    This moves the bar significantly for web developers. Better RTL support, better line-clamping behaviour with multiple boxes which people do complain about.

  14. removed
    requires:spec
    on Nov 29, 2021
  15. 8 remaining items

  16. added
    agenda
    and removed on Aug 8, 2022
  17. added and removed
    agenda
    on Aug 18, 2022
  18. foolip commented on Sep 16, 2022

    @foolip
    Member

    I'll go ahead and close this. This was an Interop 2022 proposal, and we should have a new issue for revisiting for Interop 2023.

  19. added
    focus-area-proposal
    and removed on Sep 16, 2022
  20. added this to the Interop 2022 milestone on Sep 16, 2022
  21. jonrimmer commented on Feb 2, 2023

    @jonrimmer

    Disappointing that this never got re-proposed for Interop 2023. This remains one of the most cited CSS compatibility problem areas: https://2022.stateofcss.com/en-US/usage/#interoperability_features_freeform

  22. chrishtr commented on Feb 2, 2023

    @chrishtr
    Contributor

    @jonrimmer I agree it's an important problem area. One reason it wasn't proposed for Interop 2023 was that we don't (yet) have a solution for the problem. One promising approach is described here; do you think it would meet your needs if that was the solution?

  23. Mouvedia commented on Apr 23, 2024

    @Mouvedia

    Can it be reopened?

  24. jensimmons commented on Apr 23, 2024

    @jensimmons
    Contributor

    Not reopened, but someone can propose this for Interop 2025 in the fall.

  25. Mouvedia commented on Sep 18, 2024

    @Mouvedia

    It seems to be covered by #702.

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

    focus-area-proposal

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions