Reputation: 46282
I have the following code:
<div style='width:40%'>
<p> "First Name1 " + FirstName1 + " Last Name1 " + LastName1 + " First Name2 " + FirstName2 + " Last Name2 " + LastName2 + "First Name3 " + FirstName3 + " Last Name3 " + LastName3 .... </p>
</div>
Note that the code I have is generated with a program but HTML code nevertheless. What happens in the code I have above is that once the text extends beyond 40% it continues on the next line but broken in between First Name and Last Name at times. . What I like to happen is that it should break at the next First Name versus somewhere in between the First Name and Last Name.
As such, I like to keep the First Name and Last Name on the same line without any breaks in between which happens at times. I tried   but that did not fix the issue.
Any help would be greatly appreciated.
Upvotes: 0
Views: 172
Reputation: 1229
You can use <br />
<div style='width:40%'>
<p> "First Name1 " + FirstName1 + "Last Name1" + LastName1 + "<br />First Name2 " + FirstName2 + "Last Name2" + LastName2 + "<br />First Name3 " + FirstName3 + "Last Name3" + LastName3 .... </p>
</div>
Upvotes: 0
Reputation: 5140
Couple options -- you can use a non-breaking space with the code
rather than a regular space following your first name.
OR you can wrap your first/last name inside a span
tag and give that span a CSS property of whitespace: nowrap
:
HTML:
<span class="no-wrap">Firstname Lastname</span>
CSS:
.no-wrap {
white-space: nowrap;
}
Upvotes: 3