HTML <button> nameAttribute
Examples
Two buttons with the same name, submitting different values when clicked:
<form action="demo_form.html" method="get">
Choose your favorite subject:
<button name="subject" type="submit" value="HTML">HTML</button>
<button name="subject" type="submit" value="CSS">CSS</button>
</form>
Choose your favorite subject:
<button name="subject" type="submit" value="HTML">HTML</button>
<button name="subject" type="submit" value="CSS">CSS</button>
</form>
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the name attribute.
Definition and Usage
The name attribute specifies a name for the button.
The name attribute is used to reference elements in JavaScript, or to reference form data after a form is submitted.
Tip:Different button elements can share the same name. This allows you to mark several buttons with the same name, enabling them to submit different values when used in a form.
Differences between HTML 4.01 and HTML5
NONE.
Syntax
<button name="name">
Attribute Values
| Value | Description |
|---|---|
| name | Specifies the name of the button. |
HTML <button> Tag Other Extensions