Casebash
Casebash

Reputation: 118932

Optional line break in HTML

<br> always breaks the line in a particular location. Is there a way to hint to the browser that a particular location is better for a line break than another?

Consider the following text when center aligned:

"Connect with UTS Library for one-click sign
in."

I'd like the browser to try to keep the lines more even

Upvotes: 1

Views: 748

Answers (2)

Krish R
Krish R

Reputation: 22721

You can also use &#160; non-breaking space

Connect with UTS Library for one-click sign&#160;in.

Upvotes: 1

BoltClock
BoltClock

Reputation: 724162

First thing that immediately comes to mind is &nbsp; which makes sense in your specific use case with the phrase "sign in":

"Connect with UTS Library for one-click sign&nbsp;in."

This prevents "sign" and "in" from being split by a line break, effectively treating it as a single word in that sense. The browser will choose the next best place to wrap the text, which would be the space between "one-click" and "sign".

Beyond strategic placements of &nbsp;, I don't think HTML offers any viable solutions for dealing with widows and orphans in text.

Upvotes: 5

Related Questions