cola
cola

Reputation: 12486

Can't break a long string/text, it exceeds the width of html div

<div id="id_div_comments"><p>body4qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq</p></div><br/><br/>
</div>

The css file:

div#id_div_comments {
    width: 400px;
}

But the string/texts exceeds the division width. What can i do to break the texts when it reaches the width of the division ?

Upvotes: 7

Views: 21312

Answers (4)

NerdBiz
NerdBiz

Reputation: 43

Old question but no correct answer, for long text this should work

#id_div_comments p{
 word-break: break-all;
}

Upvotes: 3

Fangming
Fangming

Reputation: 25280

The accepted answer doesn't work for me

After seaching around, the following css actually works

#id_div_comments p{
 overflow: hidden;
}

Just trust me

enter image description here

Upvotes: 4

rajesh
rajesh

Reputation: 1485

Try this code:

#id_div_comments p{
 white-space:normal;
}

Upvotes: 7

sandeep
sandeep

Reputation: 92863

wirte this in your css word-wrap:break-word; css:

#id_div_comments p{
 word-wrap:break-word;
}

Upvotes: 34

Related Questions