#1287: Other Spec Review: CSS line-clamp

Visit on Github

Opened Sep 29, 2026

Specification

https://drafts.csswg.org/css-overflow-4/#suppressing-excess

Explainer

https://github.com/Igalia/explainers/blob/main/css/line-clamp/README.md

Links

The specification

Where and by whom is the work is being done?

Feedback so far

You should also know that...

  • -webkit-line-clamp has been supported in all mainstream browser engines for years, even though it was not specified anywhere. There are cases, however, where the legacy behavior of mainstream engines is interoperable but where this specification changes the behavior. We don't expect breakage in the wild, since browsers aren't interoperable in many other cases, but it is possible that we might find some.

    • In the legacy behavior, content after the clamp point renders normally, except it is usually outside the box of the -webkit-line-clamp container, so that needs overflow: hidden to hide it. In the spec'd behavior, content after the clamp point becomes invisible and is counted as ink overflow, so overflow: hidden is not needed.
    • In the legacy behavior, if the ellipsis wouldn't fit at the end of a line, glyphs and atomic inlines would be removed off the end of the line to make it fit, as with text-overflow: ellipsis. In the spec'd behavior, inline content at the end of the line is displaced until the last soft wrap opportunity such that the ellipsis fits; and if there are none, the entire contents of the line are displaced.
    • In the legacy behavior, floats can overflow the -webkit-line-clamp container, but since overflow: hidden is almost always used, in practice they will be always clipped to the padding box. In the spec'd behavior, float clearance is not taken into account for the container's automatic sizing (meaning that floats can overflow despite the container establishing an independent formatting context), and floats before the clamp point are clipped to the container's content edge.
  • Review on the naming of line-clamp's longhands would be appreciated. For example, there were questions raised on the name of the block-ellipsis property, since its keywords are ellipsis and no-ellipsis (see https://github.com/w3c/csswg-drafts/issues/13670#issuecomment-4179822644). We would also appreciate feedback on the name of the continue property, considering also that there are plans to extend this property to handle channeling overflow (https://drafts.csswg.org/css-overflow-5/#fragmentation).

  • In Chromium, we are planning to ship line-clamp soon. We would only be shipping line-clamp as a longhand, and only ship its longhands at some point in the future. We will also be changing the legacy behavior of -webkit-line-clamp to match line-clamp at the same time.

<!-- Content below this is maintained by @w3c-tag-bot -->

Track conversations at https://tag-github-bot.w3.org/gh/w3ctag/design-reviews/1287

Discussions

Log in to see TAG-private discussions.