Skip to content

[css-overflow] How do empty blocks affect line-clamping by height? #12663

@andreubotella

Description

@andreubotella
<div style="line-clamp: auto; max-height: 2lh">
  <!-- Possible clamp point A -->
  <div>Line 1</div>
  <!-- Possible clamp point B -->
  <div>Line 2</div>
  <!-- Possible clamp point C -->
  <div></div> <!-- Takes up zero height -->
  <!-- Possible clamp point D -->
  <div>Line 3</div>
</div>

The way line-clamp is currently defined, the last possible clamp point that doesn't overflow would be chosen, and since the div between C and D takes up zero height, we'd clamp at clamp point D. By the rules of block-ellipsis, then this would mean that line 2 would not be ellipsized, since there are more things other than absolutely positioned elements and end-of-elements between the line box and the clamp point. Should this be the case?

This is similar to the discussion about abspos in #10868 (comment), with the difference that an abspos has no rendering differences whether the clamp point is before or after it, since abspos will render unless their containing block is completely after the clamp point (see #11379 and #11962). But this is not true for zero-height blocks:

  • A zero-height block could be the containing block for an abspos, meaning that the abspos will be shown or hidden depending on whether the clamp point is before or after the CB.
  • A block could be explicitly set to have height: 0 while having content that visibly overflows.

So, should empty / zero-height blocks be treated specially when choosing a clamp point, or when determining whether a line box should be ellipsized?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions