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.
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.
You should use textarea to support multiple-line inputs.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With