HTML/Elements/textarea

From Web Education Community Group
< HTML‎ | Elements
Jump to: navigation, search

<textarea>

The <textarea> element represents a multiline plain text edit control for the element's raw value.

HTML Attributes

  • autofocus = boolean
    Allows the author to indicate that a control is to be focused as soon as the page is loaded


  • cols = valid non-negative integer
    specifies the expected maximum number of characters per line. by defult, it is 20.


  • disabled = boolean
    If present, make the control non-interactive and to prevent its value from being submitted.


  • form = the ID of a form element in the element's owner
    Associate the textarea element with its form owner.
    By default, the textarea element is associated with its nearest ancestor form element.


  • name = unique name
    Represents the element's name.


  • placeholder = sample value or a brief description of the expected format
    Represents a hint (a word or short phrase) intended to aid the user with data entry.
    The placeholder attribute should not be used as an alternative to a label.


  • readonly = boolean
    Control whether the text can be edited by the user or not.


  • required = boolean
    When specified, the user will be required to enter a value before submitting the form.


  • rows = valid non-negative integer
    Specifies the number of lines to show. by defult, it is 2.


  • wrap = soft/ hard
    • soft
      The Soft state indicates that the text in the textarea is not to be wrapped when it is submitted (though it can still be wrapped in the rendering).
    • hard
      The Hard state indicates that the text in the textarea is to have newlines added by the user agent so that the text is wrapped when it is submitted.
      If the element's wrap attribute is in the Hard state, the cols attribute must be specified.


See also global attributes.


Examples

Example A

Here is an example of a textarea being used for unrestricted free-form text input in a form [try it]:

<p>If you have any comments, please let us know: 
  <textarea cols="80" name="comments"></textarea>
</p>

Textarea01.png

HTML Reference

The HTML5 specification defines the <textarea> element in 4.10.13 The textarea element.