Is there a CSS property that will make text try to fit onto 2 lines?
I could use a non-breaking space character to prevent a single orphaned word, but I thought there was a smarter property for new browsers which makes the text intelligently wrap so that both lines are of a similar length?
There is a rather new CSS property called text-wrap. You can set it to balance, although the property is only supported in Edge, Chrome and Opera: https://caniuse.com/css-text-wrap-balance
p {
max-width: 250px;
}
p.balance {
text-wrap: balance;
}
<p>this is my text and i dont like how it wraps</p>
<p class="balance">this is my text and i dont like how it wraps</p>
2
Answers
There is a rather new CSS property called
text-wrap
. You can set it tobalance
, although the property is only supported in Edge, Chrome and Opera:https://caniuse.com/css-text-wrap-balance
You could make the whole thing in a div with a specified width and adjust the width until it made the lines equal.