CSS Text Wrapping Control

Control text wrapping and overflow with CSS line-clamp text-wrap balance and overflow properties for content layout.

CssConfig Management

Code

.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.balance {
  text-wrap: balance;
}

.pretty {
  text-wrap: pretty;
}

CSS Text Wrapping Control

Control text wrapping and overflow with CSS line-clamp text-wrap balance and overflow properties for content layout.

Code

.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.balance {
  text-wrap: balance;
}

.pretty {
  text-wrap: pretty;
}

Explanation

line-clamp caps the visible lines with an ellipsis while text-wrap: balance evens out headline line lengths. Expected behavior: overflow beyond the clamp is hidden and the element keeps the clamped height. Caveat: -webkit-line-clamp requires display:-webkit-box and is a legacy-prefixed property, so pair it with an overflow fallback.

Interactive Tools for This Topic