6
<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 ?

cola
  • 12,198
  • 36
  • 105
  • 165

4 Answers4

33

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

#id_div_comments p{
 word-wrap:break-word;
}
sandeep
  • 91,313
  • 23
  • 137
  • 155
  • 1
    The support for "word-wrap: break-word" is still buggy in most browsers, unfortunately. (https://code.google.com/p/chromium/issues/detail?id=249787&thanks=249787&ts=1371225408) It does work in simple cases, though. "overflow: auto" does not (nor is supposed to) break words at all, it just adds a scrollbar if needed – matteo Jun 14 '13 at 16:07
7

Try this code:

#id_div_comments p{
 white-space:normal;
}
rajesh
  • 1,475
  • 10
  • 23
3

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

Community
  • 1
  • 1
Fangming
  • 24,551
  • 6
  • 100
  • 90
3

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

#id_div_comments p{
 word-break: break-all;
}
NerdBiz
  • 43
  • 4