1

Hi i doing comment box in my webpage so that i am doing a validation of that comment box by not allowing the user to enter the empty comment, and a comment sholud not be greater than 255 characters it all working fine but when i enter the comment like this means

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaakjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

this string is overflowing out of the comment box div i.e it is going like a straight line I had used css property overflow: auto; but wat i need is it should be shown like this. it should split the string

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaakjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

for ex: when i comment like this The p element has both line boxes and a child box for the q element, which is a block-level element. The line boxes before the q are wrapped in an anonymous block-level box and so are the line boxes after the q. The resulting tree of boxes might be as fol

it coming up proper ... it should like this

kapa
  • 77,694
  • 21
  • 158
  • 175
Siva
  • 3,458
  • 8
  • 25
  • 26
  • 1
    Can you post the HTML of your comment box? – shanethehat Apr 13 '11 at 09:33
  • possible duplicate of [CSS: how can I force a long string (without any blank) to be wrapped in XUL and/or HTML](http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and-o) – Gabriele Petrioli Apr 13 '11 at 09:37

2 Answers2

9

What you need is CSS word-wrap: break-word;. It is widely supported among browsers.

word-wrap on CSS3.info

word-wrap: break-word

kapa
  • 77,694
  • 21
  • 158
  • 175
2

You can use CSS3 property to solve your question:

.text_wrap {
  word-wrap: break-word;
}
Igor Popov
  • 924
  • 8
  • 14