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 ?

shibly
  • 11,690
  • 35
  • 99
  • 163

4 Answers4

30

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

#id_div_comments p{
 word-wrap:break-word;
}
sandeep
  • 88,914
  • 23
  • 135
  • 154
  • 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
5

Try this code:

#id_div_comments p{
 white-space:normal;
}
rajesh
  • 1,451
  • 10
  • 21
2

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
  • 23,035
  • 4
  • 95
  • 87
0

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

#id_div_comments p{
 word-break: break-all;
}
NerdBiz
  • 13
  • 3