views:

97

answers:

2
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.

+1  A: 
JapanPro
None of the examples you gave me actually work, the only one that does is `word-wrap`.
Joshua
alternative is {overflow: hidden;} and {overflow: auto;} but there is a problem to that as well.
JapanPro
Yeh, but that isn't what I'm looking for as `overflow: hidden;` would hide everything off the edge. :/
Joshua
A: 

use white-space: wrap;. If you have set width on the element on which you are setting this it should work.

update - rendered data in Firefox alt text

Vinay B R
Nope, still nothing. This code still displays the full text with horizontal scrollbar. `body { width: 768px; white-space: wrap;}`
Joshua
just setting width takes care of wrapping the text a you need(atleast on firefox). can you check behaviours on specific browsers and update the post
Vinay B R
i have updated my answer to include rendered result on firefox.
Vinay B R
This still does not work for me, I've edited my question to say what browser this is for.
Joshua
Actually got it working now! Was accidentally overriding the width without noticing!
Joshua