HTML <button> nameAttribute

HTML button 标签参考手册HTML <button> Tag

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>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 标签参考手册HTML <button> Tag Other Extensions