Boneyard Tools

CSS Line Clamp Generator

Cut text off after a chosen number of lines and add an ellipsis using pure CSS. Set the line count and copy the line-clamp rule, with a one-line alternative for single-line truncation.

How to generate line clamp CSS

  1. Set how many lines of text to keep before truncating.
  2. Preview how the clamped text looks at that line count.
  3. Copy the CSS and apply it to the text container.

Examples

Clamp to three lines

lines 3
-webkit-line-clamp: 3;

Single line

lines 1
-webkit-line-clamp: 1; (plus a white-space alternative)

Frequently asked questions

How does multi-line clamping work?

The container becomes a -webkit-box laid out vertically, line-clamp limits the number of visible lines, and overflow: hidden hides the rest while the browser adds an ellipsis.

Is -webkit-line-clamp widely supported?

Yes. Despite the -webkit- prefix it works across modern browsers including Firefox, so the prefixed form is the standard way to clamp text today.

Why is there a separate one-line option?

For a single line you can use white-space: nowrap with text-overflow: ellipsis, which is simpler and avoids the box model, so the tool includes that alternative when you pick one line.

Does the element need a fixed height?

No. Line clamp limits by line count, not height, so the element grows to the clamped number of lines and truncates anything beyond it.

Is anything sent to a server?

No. The CSS is generated entirely in your browser and your settings are never uploaded.

Related tools