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 am freshman!"
here have used named character reference
, 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 am
write <nobr>i am</nobr>
or, more clumsily conforming “standards”, <span style="white-space: nowrap">i 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
Post a Comment