How to limit text to n lines with CSS

Tag: |   Category:

The easiest way to limit text to n lines is to use line-clamp. N can be any positive number, but it will be two or three lines most of the time.

.classname {
   overflow: hidden;
   text-overflow: ellipsis;
   display: -webkit-box;
   -webkit-line-clamp: 2; /* number of lines to show */
           line-clamp: 2; 
   -webkit-box-orient: vertical;
}
Copyright © 2024 Siam Naulak.
magnifiercrossmenu