HTML <button> name attribute
Definition and Usage
name
Attribute specifies the name of the <button> element.
name
Attributes are used to reference form data after submitting the form, or to reference the element in JavaScript.
Tip:Multiple <button> elements can share the same name. This allows you to have multiple buttons with the same name that can submit different values when used in a form.
Example
Two buttons with the same name submit different values when clicked:
<form action="/action_page.php" method="get"> Please select your favorite subject: <button name="subject" type="submit" value="HTML">HTML</button> <button name="subject" type="submit" value="CSS">CSS</button> </form>
Syntax
<button name="name">
Attribute Value
Value | Description |
---|---|
name | Specifies the name of the button. |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |