HTML <textarea> form Attribute

Last Updated : 23 May, 2026

The form attribute in <textarea> is used to associate the textarea with a specific <form> element. It allows the textarea to work with a form even when placed outside the <form> tag.

  • Connects a <textarea> to a form using the form’s id.
  • Allows textarea data to be submitted even when placed outside the <form> element.
  • Useful for flexible webpage layouts and supported in HTML5.

Syntax:  

<textarea form="form_id"> 
  • form_id: It Contains the value i.e form_id which specify the one or more  form that the Textarea element belongs to. The value of this attribute should be id of the <form> element.
html
<!--Driver Code Starts-->

<!DOCTYPE html>
<html>

<head>
    <title>Textarea Form Attribute</title>
    <style>
    }
    fieldset {
        width: 50%;
        margin-left: 22%;
    }
    h1 {
        color: green;
    }
    </style>
</head>

<!--Driver Code Ends-->

<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>&lt;textarea&gt; form Attribute</h2>
        <textarea form="mygeeks" cols="20" ;>
            GeeksForGeeks. A computer science portal for Geeks
        </textarea>
        <br>
        <form id="mygeeks">
            Name:
            <input type="text" name="usrname">
            <input type="submit">
        </form>
    </center>
</body>

<!--Driver Code Starts-->

</html>

<!--Driver Code Ends-->
Comment