1

I am using IE8 and I have textarea on the page. It's width set to 80% with maxlength of 132 chars.
If the user write text that not contains spaces, like the letter V 132 times without spaces, the textarea grows horizontaly (width grows).
How can I prevent this behaviour - I don't want allow the width to grow?

3 Answers 3

4

Use word-wrap: break-word; to wrap the long unbroken line.

textarea
{
    word-wrap: break-word;
}

http://jsfiddle.net/bLKPq/2/

5
  • I don't want to hide the text - I just want to prevent the textarea from expanding.
    – Naor
    Dec 1, 2011 at 7:26
  • You want to prevent it from expending, or to limit the input size? Dec 1, 2011 at 7:30
  • @Naor overflow hidden hide the scrollbar even though you can see the expanded text.
    – Punit
    Dec 1, 2011 at 7:31
  • @Michael Sazonov: prevent it from expending.
    – Naor
    Dec 1, 2011 at 7:45
  • @punit: putting long text without spaces expand the textarea width and this is what I want to prevent.
    – Naor
    Dec 1, 2011 at 7:45
1

Set rows and cols property to it

0
0

Just need to add:

textarea
{
    word-break:break-all;
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.