Path: blob/main/files/en-us/web/css/-webkit-line-clamp/index.md
6552 views
------{{CSSRef}}
The -webkit-line-clamp CSS property allows limiting of the contents of a {{Glossary("block")}} to the specified number of lines.
It only works in combination with the {{cssxref("display")}} property set to -webkit-box or -webkit-inline-box and the {{cssxref("-webkit-box-orient")}} property set to vertical.
In most cases you will also want to set {{cssxref("overflow")}} to hidden, otherwise the contents won't be clipped but an ellipsis will still be shown after the specified number of lines.
When applied to anchor elements, the truncating can happen in the middle of the text, not necessarily at the end.
Note: This property was originally implemented in WebKit and has some issues. It got standardized for legacy support. The CSS Overflow Module Level 3 specification also defines a {{cssxref("line-clamp")}} property, which is meant to replace this property and avoid its issues.
Syntax
none: This value specifies that the content won't be clamped.
{{cssxref("integer")}}
: This value specifies the number of lines after which the content will be clamped. It must be greater than 0.
Formal definition
{{CSSInfo}}
Formal syntax
{{CSSSyntax}}
Examples
Truncating a paragraph
HTML
CSS
Result
{{EmbedLiveSample("Truncating_a_paragraph", "100%", "130")}}
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{cssxref("line-clamp")}}