The
tag is used to create a multi-line text input field in a form. It allows users to input multiple lines of text, which can be submitted as part of a form submission.
The
tag has several attributes that can be used to customize its appearance and behavior:
name
: Specifies the name of the text area. This name is used when the form is submitted to identify the input.
rows
: Specifies the number of rows that the text area will display. This controls the height of the text area.
cols
: Specifies the number of columns that the text area will display. This controls the width of the text area.
disabled
: Disables the text area, preventing it from being edited or clicked.
form
: Specifies the form that the text area belongs to. This attribute is useful if the text area is not inside a form element.
maxlength
: Specifies the maximum number of characters that can be entered in the text area.
placeholder
: Specifies a hint that will be displayed in the text area before the user inputs any text.
readonly
: Makes the text area read only, preventing it from being edited.
required
: Specifies that the text area must be filled out before submitting the form.
Here’s an example of a basic
:
When the form is submitted, the value of the text area will be sent as part of the form data with the key message
.
You can also set attributes like disabled
or readonly
to control the behavior of the text area:
Or set attributes like placeholder
or required
:
This will display a placeholder in the text area that the user can input their message in, and the form will not be submitted unless the text area is filled out.