HTML <button> name Attribute

The name attribute on a <button> tag assigns a name to the button. This name is used during form submission and as a reference for other purposes.

Example

#

Three <button>s with name and value attributes.
Clicking a button will send the button value to the form-handler.

<form action="/tutorial/action.html">
  <button name="color" type="submit" value="Red">Red</button>
  <button name="color" type="submit" value="Blue">Blue</button>
  <button name="color" type="submit" value="Green">Green</button>
</form>

Tip: Buttons with the same name, but with different values, make it easy to identify the button that submitted the form.


Using name

The name attribute assigns a name to the button.

Unlike id, the name does not have to be unique across the page.

This attribute is used as reference for JavaScript and for form data submission.

Multiple <button> elements can have the same name, but with different values.


Syntax

<button name="name">

Values

#

Value Description
name String value. The button name.

Browser support

Here is when name support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <button>
Guides