coding180 icon

Coding180

HTML Elemnt: Form - textarea

HTML Elemnt: Form - textarea

Tutorials > HTML > HTML Form Elements


The textarea type element allows us to enter several lines of text, unlike the text box (input:text).

It is very useful when we want to enter a comment with a long character length.

Let's make a form so that a visitor can enter their name, their email and a comment about a site.

<!DOCTYPE html>
<html>
<head>
  <title>Form textarea - robort </title>
  <meta charset="UTF-8">
</head>
<body>
  <form action="registration.php" method="post">
  Enter your name:
  <input type="text" name="name" size="30"><br>
  Enter your email:
  <input type="text" name="mail" size="50"><br>
  Comments:<br>
  <textarea name="comments" rows="5" cols="60"></textarea>
  <br>
  <input type="submit" value="Submit">
</form>
</body>
</html>

The result in the browser is:

HTML textarea form

The syntax to define a text area for multiline input is:

<textarea name="comments" rows="5" cols="60"></textarea>

It is an element that requires a start tag and an end tag.

In addition to having a name attribute similar to the other elements related to forms, it has two attributes called rows and cols. These two properties indicate the number of rows and columns that the text area displays.


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel