body { word-wrap: break-word;}
I've been using that code (above) to fit the text in the body
into it's container. However what I don't like about it, is that it breaks up words.
Is there another way where it will not break up words and only line break after or before a word?
EDIT: This is for use within a UIWebView
.
Keep words on the same line Word automatically breaks the text at a space or a hyphen at the end of a line. To keep two words or a hyphenated word together on one line, you can use a nonbreaking space or nonbreaking hyphen instead of a regular space or hyphen. Click where you want to insert the nonbreaking space.
use white-space: nowrap; . If you have set width on the element on which you are setting this it should work. It's white-space: nowrap actually.
How to Prevent Word Wrap on a Web Page: HTML Method. If you only have the one-off instance of two or more words that you want to force the browser to keep on a single line, the easiest way is to use the non-breaking space character, " ", to separate those words instead of a normal space.
use white-space: nowrap;
. If you have set width on the element on which you are setting this it should work.
update - rendered data in Firefox
May be a bit late but you can add this css to stop word breaks:
.element { -webkit-hyphens: none; -moz-hyphens: none; -ms-hyphens: none; hyphens: none; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With