wong2
wong2

Reputation: 35760

Unexpected line wrap

A very simple html:

<div style="width:200px">
    <p>f 22222222222222222222222222</p>
</div>

will be rendered as:

f 
22222222222222222222222222

and what I was expected is:

f 222222222222222
22222222222

is it possible to fix this?

Fiddle: http://jsfiddle.net/8yL6j/

Upvotes: 0

Views: 233

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201896

It seems that you would like browsers to put as many characters on a line that fit there and then break, with no regard to normal line breaking behavior, rules of languages, etc., then use word-break: break-all on the element.

Upvotes: 1

Blender
Blender

Reputation: 298582

Use word-wrap: break-word to break the text up in the middle of a word:

.container {
    width: 200px;
    word-wrap: break-word;
}​

Demo: http://jsfiddle.net/8yL6j/1/

Upvotes: 1

Related Questions