HTML <form> name Attribute
Example
An HTML form with a name attribute:
<form
action="form_action.asp"
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>
Try it yourself »
Definition and Usage
The name attribute specifies the name of a form.
The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.
Browser Support
Attribute | |||||
---|---|---|---|---|---|
name | Yes | Yes | Yes | Yes | Yes |
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