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

Manual de Referência HTML

大全 de Tags HTML

HTML: Atributo name do elemento <button>

O atributo name especifica o nome do elemento <button>, vários elementos <button> podem compartilhar o mesmo nome. Isso permite que você use vários botões com o mesmo nome, que, ao serem usados em formulários, poderão submeter valores diferentes

 HTML <button> tag

Exemplo Online

Dois botões com o mesmo nome, ao serem clicados, submeterão valores diferentes:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Uso do atributo name do elemento <button> em HTML-Tutorial Básico(oldtoolbag.com)</title>
</head>
<body>
<form action="action_page.php" method="get">
  Escolha o tema que você deseja favoritar:
  <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