Limit text length to a specified number of lines

Posted on Mar 25, 2025

by Jimmy

CSS

How to use the line-clamp CSS property to limit text to a specific number of lines.

CSS
        
            .text {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* number of lines to show */
    -webkit-box-orient: vertical;
}        
    

See this Stackoverflow post for more information.


Back to Snippets