HTML textarea tag

HTML <textarea> tag defines multi-line textarea having height and width as rows and columns. We can apply different attributes on textarea to make it more usable.

<textarea cols="25" rows="9">
  It is textarea. It is editable and resizeable by default.But the size  can be fixed. 

Tag omission

Both starting and ending tags are necessary for the textarea element.

Global Attributes

All the global attributes are applicable on the textarea element.

Tag Attributes

Attributes that are applicable to <textarea> tag

browser suggests different options to the user for form autocomplete.

<textarea autocomplete> the content goes here </textarea>

automatically focus the control to the specified input field after page loading.

<textarea autocomplete> the autofocus attribute is here </textarea>

represents the width (no of characters per line) of the textarea.

<textarea cols="an integer"> the cols attribute is here </textarea>

It makes the input field uneditable and unprocessable.

<textarea disabled> the disabled textarea </textarea>

represents form to collect the information.

<textarea form="id of the form element"> the plain text </textarea>

It specifies the maximun value in the input field.

<textarea maxlength="an integer"> maximum number of characters </textarea>

It specifies the minimum value in the input field.

<textarea minlength="an integer"> minimum number of characters </textarea>

It specifies a unique name to use for submission with form.

<textarea name="text"> unique name of textarea </textarea>

It places the user-visible content in the input field.

<textarea placeholder="text"> water mark type text </textarea>

The content inside input field can be read only.

<textarea readonly> Here you can not edit </textarea>

forces the user to put value in input field.

<textarea required> You must enter the text here </textarea>

represents the height (no of lines) of the textarea.

<textarea rows="integeral value"> no of lines to show </textarea>

Was this article helpful?