« Previous Tutorial Next Tutorial »

Textarea is similar to the text box except in the text box, you can enter only a single line of information, whereas, in the textarea, you can enter multiple lines of information.

The content provided within the starting and the ending tags of the TEXTAREA tag should only be plain text. You can adjust the size of the textarea by using the two attributes i.e. cols and rows.

The wrap attribute of the TEXTAREA tag defines how the text appears in the textarea field when it reaches the end of every row. Wrapping can have soft, hard, and off settings.

The soft setting forces the words to wrap inside the textarea, but when the form is submitted, it includes the line breaks.

The hard setting wraps the words inside the textarea and places line breaks at the end of each line so that when the form is submitted, it appears exactly as it appears in the textarea. The offsetting ignores all the wrapping in the textarea and places the text into one ongoing line.

Attributes of the TEXTAREA tag

The following table describes the attributes of the TEXTAREA tag.

Attribute Description
cols Refers to the visible width of the textarea control
rows Refers to the permitted number of rows in the textarea control
disabled Disables the textarea
name Refers to the name of the textarea
readonly Specifies that the textarea is read-only and you cannot write in it
accesskey Refers to the shortcut key on the keyboard
autofocus Allows the control to get the focus as soon as the page loads
dirname Specifies the name of the input control that indicates the text direction of the textarea
maxlength Specifies the maximum number of character that can be entered in the textarea
placeholder Helps the user to fill the respective textarea by providing the hint for the input
required Specifies that the value of the input field is required to submit the form
wrap Allows the textarea to wrap the text

Some controls, such as button control, do not require any description as they already have labels associated with them, whereas, some controls, such as text boxes, check boxes, and radio buttons, need description.

You can provide the description of the control by adding a label on the form using the LABEL tag. Each LABEL is associated with exactly one control.

Attributes of the LABEL tag

The following table describes the attributes of the LABEL tag.

Attribute Description
For Associates the label with a specific control. The value of this attribute must match the id attribute of its associated control.
form Refers to the id of a form

HTML Online Test

« Previous Tutorial Next Tutorial »

© Copyright 2021. All Rights Reserved.