English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <button> name Attribute

The name attribute specifies the name of the <button> element, several <button> elements can share the same name. This allows you to use multiple buttons with the same name, which can submit different values when used in a form

 HTML <button> tag

Online Example

Two buttons with the same name, which submit different values when clicked:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <button> name Attribute Usage-Basic Tutorial(oldtoolbag.com)</title>
</head>
<body>
<form action="action_page.php" method="get">
  Select the theme you want to collect:
  <button name="subject" type="submit" value="HTML">HTML</button>
  <button name="subject" type="submit" value="CSS">CSS</button>
</form>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the name attribute.

Definition and Usage

The name attribute specifies the name of the <button> element.
The name attribute is used to reference form data after form submission, or to reference elements in JavaScript.
Hint: Several <button> elements can share the same name. This allows you to use multiple buttons with the same name that can submit different values when used in a form.

HTML 4.01 and HTML5differences between

None.

Syntax

<button name="name">

Attribute value

ValueDescription
nameSpecifies the name of the button.
 HTML <button> tag