English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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>.
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 ‹/›
IEFirefoxOperaChromeSafari
Todos os navegadores populares suportam a tag <button>.
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.
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.
HTML5 New attributes: autofocus, form, formaction, formenctype, formmethod, formnovalidate, and formtarget.
New: HTML5 new attribute.
Attribute | Value | Description |
---|---|---|
autofocusHTML5 | autofocus | Define that the button should automatically receive focus when the page is loaded. |
disabled | disabled | Define that the button should be disabled. |
formHTML5 | form_id | Define that the button belongs to one or more forms. |
formactionHTML5 | URL | Define 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". |
formenctypeHTML5 | application/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". |
formmethodHTML5 | get 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". |
formnovalidateHTML5 | formnovalidate | If 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". |
name | name | Define o nome do botão. |
type | submit reset button | Define o tipo do botão. |
value | text | Define o valor inicial do botão. Pode ser modificado pelo script. |
Suporte do <button> tag Atributos globais do HTML.
Suporte do <button> tag Atributos de evento do HTML.
Manual de referência do DOM HTML: Object Button