property

Line clamp — CSS reference

Limits the amount of block content displayed to a specified number of lines, with ellipsis behavior governed by the relevant shorthand components. The widely used prefixed combination requires -webkit-box and vertical box orientation. Provide a way to reveal important truncated content.

Formal Syntax & Structure

css syntaxcss
line-clamp: 2;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>line-clamp</title><style>body{margin:8px;font:16px/24px sans-serif}#a{width:180px;line-height:20px;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2}</style><body><p id="a">First line<br>Second line<br>Third line<br>Fourth line</p></body></html>
CSS Reference