Categories
Web development

HTML textarea tag

HTML textarea tag

The HTML <textarea> tag specifies a multi-line text input control.

The HTML <textarea> tag is often used in a form, to collect user inputs like reviews or comments, etc.

You can define a size of a text area by the <cols> and <rows> attributes or by using CSS.

cols (value- number) – defines the visible width of a text area.

rows (value- number) – defines the visible number of lines in a text area.

The HTML id attribute is used to connect the text area with a label.

Example1:

This text area has 4 visible rows:

<!DOCTYPE html>
<html>
<body>

<form action="">
<label for="ldesign">lenadesign text:</label>
<textarea id="ldesign" name="ldesign" rows="5" cols="50">Hi, I’m Lena, thank you for taking the time to browse my content on lenadesign.org. I hope you’ve found some useful stuff so far.
  </textarea>
  <br>
</form>

</body>
</html>

Output:


Always remember to add the name attribute to reference the form data (in case you omit the name attribute, no data from the text area will be submitted).

name (value- text) – defines a name for a text area.

Example2:

<!DOCTYPE html>
<html>
<body>

<form action="">
<textarea rows="4" cols="50" name="someText">Type your text here...</textarea>
</form>

</body>
</html>

Output:

Enjoy coding!

Read also:

HTML form tag

HTML input tag

HTML Radio Buttons