HTML <button> name Attribute
Example
Two buttons with equal names, that submit different values when clicked:
<form action="/action_page.php" 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>
Try it Yourself »
Definition and Usage
The name
attribute specifies the name for a
<button>
element.
The name
attribute is used to reference form-data after
the form has been submitted, or to reference the element in a JavaScript.
Tip: Several <button>
elements can share the same name. This allows you
to have several buttons with equal names, which can submit different values when
used in a form.
Browser Support
Attribute | |||||
---|---|---|---|---|---|
name | Yes | Yes | Yes | Yes | Yes |
Syntax
<button name="name">
Attribute Values
Value | Description |
---|---|
name | The name of the button |
❮ HTML <button> tag
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.