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

2

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Won't word-wrap cause some problems with older browsers, being a CSS3 feature?
It was standardized in CSS3, though it has existed for a long time. caniuse.com/#search=word-wrap
Thanks for that. Ignore my answer, this is probably your best option. :)
2

You can use CSS3 property to solve your question:

.text_wrap {
  word-wrap: break-word;
}

3 Comments

How is this different from my earlier answer? :)
I just started type my answer before you answer was published and published my answer after you :)
Happens a lot to me either :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.