# Multi-line Truncate

> Cut text off after a set number of lines and end it with an ellipsis.

- Category: [CSS Text Effects](https://copy-css.com/category/text)
- Tags: line-clamp, truncate, ellipsis, overflow, excerpt
- Live preview: https://copy-css.com/snippets/line-clamp
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<p class="clamp">CSS can trim long text to a set number of lines and add an ellipsis at the end. There is no JavaScript and no measuring, and it keeps working as the container resizes.</p>
```

## CSS

```css
.clamp {
  --lines: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--lines);
  line-clamp: var(--lines);
  overflow: hidden;
}
```

## Notes

- This CSS Multi-line Truncate is 8 lines of pure CSS (0.2 KB) with no JavaScript and no dependencies. It uses line clamping and custom properties.
- Customize with: `--lines`.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
