Reputation: 497
I have an
<input type="text" />
box. The data in my box is quite long so I set the height to 100px. However the text just goes from left to right and does not wrap. Is there any way I could make it wrap?
Hoping for some good suggestions.
Thanks,
Upvotes: 10
Views: 31788
Reputation: 3058
With the style attr
, or with CSS, you can do this:
<textarea
id="temp"
style="white-space: pre-wrap; height: 100px; width: 500px;"
>This is my text box. And it can wrap.</textarea>
The same thing can be done in jQuery with:
$('#dom_id').attr("style", "white-space: pre-wrap");
This will hold for both textbox and text area.
Upvotes: 0
Reputation: 8884
No, you can't make an input element do that. Use textarea instead.
Upvotes: 3
Reputation: 56769
You need to use a <textarea>
instead for input text that wraps.
Upvotes: 15