Text Area in HTML Forms for multiline data input:
Text Area Forms multi line data input: Occasionally, we are required to seek user input in the form of detailed note or paragraphs. This becomes tricky because with the single line input tag lengthy arguments and text cannot be obtained from users. The tag <textarea></textarea> allows the user to input multiline data into html forms. A ‘textarea’ tag has a few attributes which include: rows and heights. Rows in ‘textarea’ define height while cols represent width of the text area box.
A text area looks like this:
A sample code for textarea is shared below for a better understanding:
Sample Code for TextArea
A Textarea looks like this:
<textarea id = “txtAnswer”
rows = “15”
cols = “30”></textarea>
- <label></label> is meant for the text that appears before the textarea
- We have wrapped <label> tag inside a paragraph<p> element. This is to separate it from the <textarea> box.
- We have also contained the <textarea> itself into a <p> paragraph.
- There is an id added to the text area.
- Rows are for the height whereas cols stand for width of the visible <textarea> box to the user.