Clamps (ie. cuts off) an HTML element's content by adding ellipsis to it if the content inside is too long.

While you can only truncate single lines with CSS by using text-overflow, this small JavaScript library also allows truncating text after multiple lines.

Please note:

  • For Internet Explorer, the element you clamp on needs to have its line-height set in pixels. A relative value will not work.
  • There is also the -webkit-line-clamp Archive CSS property, but that won't work in Firefox let alone IE.
Arne Hartherz almost 7 years ago
This website uses short-lived cookies to improve usability.
Accept or learn more