Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<input> multi-line capable via CSS

Is there a way to get an <input />-field in HTML to wrap lines if the text is longer than the field using CSS? I don't want to use <textarea /> as I want to avoid users entering hard line-breaks by pressing enter.

like image 301
Bob Avatar asked Aug 24 '09 21:08

Bob


People also ask

How do you make a multi-line input?

To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.

What control user can input multiple lines?

You should use textarea to support multiple-line inputs.

Which HTML is used to define a multiline input field?

The HTML <textarea> tag is used to specify a multiline input control text area in HTML5. The <cols> and <rows> attributes specify size of a textarea.


2 Answers

No, sorry. <input type=text> is single line by definition. See the W3C document Forms in HTML Documents:

text
    Creates a single-line text input control.
like image 107
RichieHindle Avatar answered Oct 12 '22 21:10

RichieHindle


Using Dojo's Dijit TextArea form control, based off TextArea, you can have an input field which begins as a single line and expands as the user adds to it.

See its documentation.

like image 30
aehlke Avatar answered Oct 12 '22 22:10

aehlke