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

Manual de Referência HTML

大全 de Tags HTML

HTML: Tag <button>

A tag <button> em HTML é um elemento que representa um botão clicável, que pode ser usado em formulários ou em outros lugares do documento onde é necessário usar um botão simples e padrão. Este marcador também é conhecido como elemento <button>.

Exemplo Online

O seguinte código marca um botão:

!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Manual Básico(oldtoolbag.com)</title> 
</head> 
<body>
<button type="button" onclick="alert('Olá, mundo!') Clique aqui</button>
 
</body>
</html>
Teste e veja ‹/›

Compatibilidade do navegador

IEFirefoxOperaChromeSafari

Todos os navegadores populares suportam a tag <button>.

Definição e instruções de uso da tag

O <button> define um botão.

Inside the <button> element, you can place content, such as text or images. This is the difference between this element and the button created using the <input> element.

The HTML <button> element is located within the <body> tag.
The <button> tag cannot be placed after the <a> tag.

Tip:Always specify the type attribute for the <button> element. Different browsers use different default values for the type attribute of the <button> element.

Tips and Notes

Note:If the <button> element is used in an HTML form, different browsers may submit different button values. Use <input> Create a button in an HTML form.

HTML 4.01 with HTML5differences

HTML5 New attributes: autofocus, form, formaction, formenctype, formmethod, formnovalidate, and formtarget.

Attribute

New: HTML5 new attribute.

AttributeValueDescription
autofocusHTML5autofocusDefine that the button should automatically receive focus when the page is loaded.
disableddisabledDefine that the button should be disabled.
formHTML5form_idDefine that the button belongs to one or more forms.
formactionHTML5URLDefine where to send the form data when submitting the form. Override the action attribute of the form element. This attribute is used in conjunction with type="submit".
formenctypeHTML5application/x-www-form-urlencoded
multipart/form-data
text/plain
Define how to encode the form data before sending it to the server. Override the enctype attribute of the form element. This attribute is used in conjunction with type="submit".
formmethodHTML5get
post
Define the HTTP method used to send form data. Override the method attribute of the form element. This attribute is used in conjunction with type="submit".
formnovalidateHTML5formnovalidateIf this attribute is used, the form will not be validated when submitted. Override the novalidate attribute of the form element. This attribute is used in conjunction with type="submit".
formtargetHTML5_blank
_self
_parent
_top
framename

Define where to open the action URL. Override the target attribute of the form element. This attribute is used in conjunction with type="submit".
Indica o nome ou palavras-chave onde a resposta deve ser exibida após o envio do formulário.Pode ser um dos seguintes valores: _self, _blank, _parent, _top

_self-Indica que a resposta será carregada no frame ou contexto atual
_blank-Indica que a resposta será carregada em uma nova janela ou contexto
_parent-Indica que a resposta será carregada no frame ou contexto pai
_top-Indica que a resposta será carregada na janela original completa

namenameDefine o nome do botão.
type

submit 

reset

button

Define o tipo do botão.
Submeter-Indica que o botão submeterá os dados do formulário ao servidor (se não for especificado o tipo, será o valor padrão)
Resetar-Indica que o botão resetará todos os controles
botão-Indica que o botão não possui comportamento padrão

valuetextDefine o valor inicial do botão. Pode ser modificado pelo script.

Atributos globais

Suporte do <button> tag Atributos globais do HTML.

Atributos de evento

Suporte do <button> tag Atributos de evento do HTML.

Artigos relacionados

Manual de referência do DOM HTML: Object Button