html - One letter word on the end of line (justify) -


i wonder can if have 1 letter word on end of text line, example:

"hello name john smith, , freshman!" 

how can move "i" next line, , have justified entire line? because when put <br> justify crashes.

here's jsfiddle http://jsfiddle.net/p3xyv/

if use no-break space u+00a0 between 2 words, instead of normal whitespace (like space or line break), browsers keep words together, on 1 line. example:

"hello name john smith, , i&nbsp;am freshman!" 

here have used named character reference &nbsp;, can use no-break space if know how type in authoring environment , have declared character encoding. in editing programs, no-break space looks normal space.

this independent of text justification. in old days, browsers used treat no-break space non-stretchable in justification. nowadays treated space in justification, i.e. gets share of added spacing.

if you’d have non-breaking non-stretchable space between words, you’d need more complicated approach. use u+2005 four-per-em space or other fixed-width space , wrap words in element line breaking forbidden html or css. example, instead of i&nbsp;am write <nobr>i&#x2005;am</nobr> or, more clumsily conforming “standards”, <span style="white-space: nowrap">i&#x2005;am</span>. there no guarantee work in future, though; there no requirement in specifications browsers support fixed-width characters way (but simple , natural implementation, , current one).


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -