
Custom CSS Text Selection Color
August 27, 2024
Custom Select Arrow using CSS
August 28, 2024
In CSS, the text-wrap: balance and text-wrap: pretty methods are used to optimize how text is wrapped within a block. Here’s a brief explanation of each:
text-wrap: balance
text-wrap: balance tries to make the lines within a block of text equal in length, so it looks more balanced and pretty. This prevents situation where some lines are way shorter than others, and makes it more readable. This is especially useful in responsive design where the width of the text block can change.
Example usage
p {
text-wrap: balance;
}
text-wrap: pretty
text-wrap: pretty is a more advanced approach that takes into account the layout of the text, not just line lengths but also sentence breaks, word placement and punctuation. The goal is to make the text look pretty. text-wrap: pretty is a concept for now and not supported in browsers yet.
Example usage
p {
text-wrap: pretty;
}
Comparison text-wrap: balance vs text-wrap: pretty
- Objective:
text-wrap: balancefocuses on equalizing line lengths, whiletext-wrap: prettyemphasizes the overall aesthetic of the text layout. - Support status:
text-wrap: balancehas more browser support, whereastext-wrap: prettyis more of a theoretical concept that may be implemented in the future. - Practical application: Currently, using
text-wrap: balanceis more practical for improving text aesthetics, especially in responsive designs.
See the Pen Untitled by Snippflow (@snippflow) on CodePen.
Summary
text-wrap: balance is more useful and supported for text wrapping in CSS. In the future, text-wrap: pretty will offer more advanced aesthetic options when browsers implement it. Both will make content on web pages more readable and look better.

