Link to home
Avatar of fonglun
fonglun

asked on

Wrapping text in TEXTAREA

I want to wrap text using html tag TEXTAREA when a long text (without spaces) is input in the textarea.
The style used for the TEXTAREA must be style="width:100%;".

Anyone can help?
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

there is predefined wrap property,
<textarea name="textarea" wrap="virtual"></textarea>

Open in new window


<textarea width="100%" wrap="virtual">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</textarea>

Open in new window

Avatar of fonglun
fonglun

ASKER

i have used all possible values for wrap but still not able to wrap the long text.
I have to scroll to far right to see the end of the long text.
please post your code on this text area?
>> The style used for the TEXTAREA must be style="width:100%;".

remove " style="width:100%;" instead , you fix COLS + Rows in the text area with WRAP..

it should
The HTML textarea input box will AUTOMATICALLY wrap text that the user enters.  If you are prefilling the textarea with your own text, you need to either set a FIXED width and height to the text area, which is the correct way to do it, or wrap the text with the code you are using to prefill the text area.

Note that the comment above, implying that you can set a textarea to 100% is not correct.  It does not recognize percentage sizes for width OR height.  You must specify REAL pixel heights, and if you do this, you will most likely have no problem --

TEXTAREA width="200" height="150"

When you fill that with data, it will automatically wrap, but it will NOT work if you use percentages -- because the percentages are meaningless to the textarea box -- a percent of what?  Doesn't make sense.
ASKER CERTIFIED SOLUTION
Avatar of aianrnoens
aianrnoens

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial