{-webkit-line-clamp} Property | CSS: Presentation Layer

Standards Based Development

-webkit-line-clamp is an unsupported WebKit property that limits the number of lines of text displayed in a block element. -webkit-line-clamp needs to be used with text-overflow:ellipsis, display:-webkit-box, and -webkit-box-orient:vertical to work. In the example below, WebKit browsers will clamp the number of visible lines in the paragraph to 2:


.clampdemo{
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}


<p class="clampdemo">
Lorem ipsum dolor sit amet, 
  consectetur adipisicing elit, sed do eiusmod tempor 
  incididunt ut labore et dolore magna aliqua. Ut enim 
  ad minim veniam, quis nostrud exercitation ullamco 
  laboris nisi ut aliquip ex ea commodo consequat. Duis 
  aute irure dolor in reprehenderit in voluptate velit 
  esse cillum dolore eu fugiat nulla pariatur. Excepteur 
  sint occaecat cupidatat non proident, sunt in culpa qui 
  officia deserunt mollit anim id est laborum.
</p>

References and Resources