Nathan
Nathan

Reputation: 1540

Is there an   that WILL allow me to line wrap?

I'm doing a simple string replacement of space ("") with   to get some rudimentary formatting (multiple spaces in a row). However I finally discovered after all these years that   actually stands for non-breaking space, and I don't get any line wraps if I do a blanket replacement on my entire string.

Is there a special html character for a space that will break? The other replacement is to simply to my replacement search for double-spaces only.

Upvotes: 2

Views: 475

Answers (1)

Justinas
Justinas

Reputation: 43481

You can use   followed by ​ to make breakpoints. It's zero-width space character that is used for making breakspaces inside words at specific points

div {
  border: 1px solid #ddd;
  width: 25px;
}
<div>a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a</div>
<div>a&nbsp;&#8203;&nbsp;&#8203;&nbsp;&#8203;&nbsp;&#8203;&nbsp;&#8203;&nbsp;&#8203;&nbsp;&#8203;a</div>

Upvotes: 5

Related Questions