Problem: Multi-Line Text Clamping

easy
15 min
Try to clamp multi-line text to a fixed number of lines with an ellipsis using CSS, preserving layout consistency.

Problem description

Clamp overflowing text after a specified number of lines (e.g., three lines), ensuring that excess text is hidden and replaced with an ellipsis.

Goal

Display only the first three lines of a paragraph and truncate the rest with an ellipsis, maintaining layout consistency.

Constraints

  • Use only CSS. No JavaScript is allowed.

  • Support dynamic and varying paragraph lengths.

  • Ensure the solution is responsive.

Sample visual output

Here’s what the output would look like:

Good luck trying the problem! If you’re unsure how to proceed, check the Solution.

Problem: Multi-Line Text Clamping

easy
15 min
Try to clamp multi-line text to a fixed number of lines with an ellipsis using CSS, preserving layout consistency.

Problem description

Clamp overflowing text after a specified number of lines (e.g., three lines), ensuring that excess text is hidden and replaced with an ellipsis.

Goal

Display only the first three lines of a paragraph and truncate the rest with an ellipsis, maintaining layout consistency.

Constraints

  • Use only CSS. No JavaScript is allowed.

  • Support dynamic and varying paragraph lengths.

  • Ensure the solution is responsive.

Sample visual output

Here’s what the output would look like:

Good luck trying the problem! If you’re unsure how to proceed, check the Solution.