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;
}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
Aspect Ratio CalculatorSimplify a width-to-height ratio, show its decimal value, and derive a matching height for a new width.Border Radius PreviewPreview four-corner border-radius values on a live box and copy the generated shorthand border-radius CSS declaration.Box Shadow GeneratorBuild CSS box-shadow values with offset, blur, spread, color, opacity, and inset controls, with a live preview of the result.CSS Color Name LookupTranslate between CSS keyword color names and hex values with RGB and HSL conversions, exact name matching, and nearest-color suggestions.
Report a problem with this exampleOpens a pre-filled issue on GitHub.