Repository navigation
Description
Description
-webkit-line-clamp is a highly used feature to clamp the number of lines shown for inline-content.
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.
-
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.
-
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:
-
Support "-webkit-line-clamp: none" only FF supports this currently, and this would round out making it a minimal when un-prefixing.
cc/ @frivoal
Activity
foolip commentedon Nov 11, 2021
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.foolip commentedon Nov 11, 2021
Survey data supporting this is in #7. Most of the responses just said "line-clamp", but these were a bit more elaborate:
jgraham commentedon Nov 11, 2021
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?
bfgeek commentedon Nov 11, 2021
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.
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.
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.
This is great! At least two (three?) of these responses are happy with the better behaviour:
(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 )
jgraham commentedon Nov 11, 2021
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"?
bfgeek commentedon Nov 11, 2021
Thats correct.
bfgeek commentedon Nov 11, 2021
(at least I believe those are the only two tests which need to be updated from my previous analysis).
bfgeek commentedon Nov 11, 2021
Potentially also: http://wpt.live/css/css-overflow/webkit-line-clamp-024.html as this is assume flex baseline behaviour instead of block baseline behaviour.
foolip commentedon Nov 23, 2021
@bfgeek I added the
requires:speclabel 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?
mrego commentedon Nov 23, 2021
From the spec side, @frivoal has been paying attention to this topic, and maybe he can help to clarify the status of things.
frivoal commentedon Nov 26, 2021
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.
bfgeek commentedon Nov 29, 2021
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.
8 remaining items
foolip commentedon Sep 16, 2022
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.
jonrimmer commentedon Feb 2, 2023
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
chrishtr commentedon Feb 2, 2023
@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?
gsnedders commentedon Feb 3, 2023
FTR, the spec is now in L4: https://drafts.csswg.org/css-overflow-4/#propdef--webkit-line-clamp
Mouvedia commentedon Apr 23, 2024
Can it be reopened?
jensimmons commentedon Apr 23, 2024
Not reopened, but someone can propose this for Interop 2025 in the fall.
Mouvedia commentedon Sep 18, 2024
It seems to be covered by #702.