Introduction:

In this article we are going to explain what is textarea tag in html or how to define multi-line text input control in html with example.

Description:

The HTML <textarea> tag is used to define a multi-line text input control. It can hold unlimited number of characters and the texts are displayed in a fixed-width font (usually courier).

The size of the HTML textarea is defined by <cols> and <rows> attribute, or it can also be defined through CSS height and width properties.

Textareas of this kind are used for comments, blogs, memos or any other purpose that requires an expression space.

Let's see an example of HTML textarea.

<!DOCTYPE html>
<html>
<head>
    <title>Example of textarea tag </title>   
</head>
<body>
    <textarea rows="9" cols="70">
        this textarea tag example with rows and columns.
    </textarea>  
</body>
</html>

 

Output:

how to use textarea in html

    New HTML 5 Textarea Attributes:


Attribute

Description

autofocus

It specifies that a text area should be automatically get focused when the page is loaded.

form

It specifies one or more forms the textarea belongs to.

maxlength

It specifies the maximum number of characters allowed in the text area.

placeholder

It specifies a short hint that describes the expected value of a textarea.

required

It specifies that textarea must be filled out.

wrap

It specifies that how the texts in the textarea are wrapped at the time of the submission of the form.












Let's see an example of HTML Textarea form attribute

The form attribute specifies one or more forms the text area belongs to.


<!DOCTYPE html>
<html>
<head>
    <title>Example of textarea tag </title>   
</head>
<body>
    <form action="updates.jsp" id="usrform">
        Name: <input type="text" name="usrname">
        <input type="submit">
    </form>
    <br>
    <textarea rows="9" cols="70" name="comment" form="usrform">
        Enter text here...
    </textarea>
    <p>The text area above is outside the form element,
         
    but should still be a part of the form.</p>
   
<p><b>Note:</b> The form attribute is not supported in Internet Explorer.</p>   
</body>
</html>

 

Output:

how to use textarea in html

I hope this article will help to you after reading.

comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like