HTML/CSSIntermediate#css#layout-puzzle

How do you truncate text with an ellipsis, including multi-line clamping?

For single-line truncation use white-space: nowrap, overflow: hidden, text-overflow: ellipsis. For multi-line clamping, use the -webkit-line-clamp property alongside display: -webkit-box, now well supported across modern browsers.

Example
.single-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multi-line {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

Related Questions

1
HTML/CSSIntermediate#css#responsive

How do you create a responsive image that maintains aspect ratio without JavaScript?

Open
2
HTML/CSSIntermediate#css#cascade

What is the CSS cascade and how is rule conflict order determined?

Open
3
HTML/CSSIntermediate#css#cascade

What does !important do and why should it generally be avoided?

Open