Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop word-wrap dividing words

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.

like image 890
Joshua Avatar asked Sep 23 '10 06:09

Joshua


People also ask

How do I stop words breaking?

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.

How do you keep words from breaking in CSS?

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 do I stop words breaking in HTML?

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.


2 Answers

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 alt text

like image 88
Vinay B R Avatar answered Oct 03 '22 13:10

Vinay B R


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; } 
like image 21
Ralphonz Avatar answered Oct 03 '22 12:10

Ralphonz