HTML <textarea>
query_builder | Christopher PisaniThe HTML element <textarea> is a multiple line text input. The difference between a <textarea> and a < input> is that the < textarea> can hold multiple lines in an input window and reserve the breaking of lines and whitespace.
Important Note :
Unlike an < input> element, <textarea> needs an opening tag <textarea> and a closing tag </textarea>
A simple <textarea> example
<style>
textarea {
width: 100%;
height: 100px;
}
</style>
<label for="textExample">
Enter some text here:
</label>
<textarea id="textExample"></textarea>
To add value to a <textarea>, you simply put the data between the opening and closing tags
<style>
textarea {
width: 100%;
height: 100px;
}
</style>
<label for="textExample">
Enter some text here:
</label>
<textarea id="textExample">Some text...</textarea>
A placeholder attribute can be used to show a title for the <textarea>
<style>
textarea {
width: 100%;
height: 100px;
}
</style>
<textarea id="textExample" placeholder="Enter some text here...">
</textarea>
Available Attributes
Attribute | Values | Functionality |
---|---|---|
autofocus | To set focus on the element when pages loads | |
cols | number | The width of the element |
dirname | The text direction of the textarea to be submitted | |
disabled | Disables the element | |
form | form's id | The id of the form it belongs to |
maxlength | number | The maximum number of charchters allowed in the element |
name | text | The name of the element |
placeholder | text | A dimmed description or title for the element |
readonly | Specifies that the element is read only | |
required | Specifies that the element can not be empty when used in a form | |
rows | number | The number of rows in the element |
wrap | Specifies that text will be wrapped in the element when used in a form |