HTML <form> nameAttribute
Examples
An HTML form with a name attribute:
<form
action="form_action.html"
method="get" name="myForm">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formSubmit()" value="Send form data!">
</form>
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formSubmit()" value="Send form data!">
</form>
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the name attribute.
Definition and Usage
The name attribute specifies the name of a form.
The name attribute is used to reference elements in JavaScript, or to reference form data after a form is submitted.
Differences Between HTML 4.01 and HTML5
None.
Differences Between HTML and XHTML
In XHTML, the name attribute is deprecated. Use the id attribute instead.
Syntax
<form name="text">
Attribute Values
| Value | Description |
|---|---|
| text | Specifies the name of the form. |
HTML <form> Tag Other Extensions