Single-line truncation uses text-overflow: ellipsis with white-space: nowrap. For multi-line truncation (e.g., limiting a blog excerpt to 3 lines), use the -webkit-line-clamp property.
The line-clamp approach works in all modern browsers despite the -webkit prefix. Set the desired number of lines and the overflow will be cleanly cut with an ellipsis.
/* Single line truncation */
.summary-title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* Multi-line truncation (3 lines) */
.summary-excerpt p {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}Find more snippets in our CSS CheatsheetTry it free →
