HTML 5 <button> Tag
Example
A button is marked up as follows:
| <button type="button">Click Me!</button> |
Try it yourself » |
Definition and Usage
The <button> tag defines a push button.
Inside a button element you can put content, like text or images. This is the difference between this element and buttons created with the input element.
Always specify the type attribute for the button. Different browsers uses
different default values for the type attribute.
Differences Between HTML 4.01 and HTML 5
HTML 5 has new attributes: autofocus,form,
formaction,
formenctype,
formmethod,
formnovalidate, and
formtarget.
Tips and Notes
Note: if you use the button element in an HTML form, different
browsers submit different button values. Use the input element to create buttons
in an HTML form.
Attributes
| Attribute |
Value |
Description |
| autofocus |
sutofocus |
Makes the button focused or not, as the page loads |
| disabled |
disabled |
Disables the button |
| form |
form_name |
Specifies which form this button belongs to |
| formaction |
url |
Specifies where to send the form-data when a form is
submitted. Overrides the forms action attribute. |
| formenctype |
application/x-www-form-urlencoded
multipart/form-data
text/plain |
Specifies how form-data should be encoded before sending it
to a server. Overrides the forms action attribute. |
| formmethod |
delete get post put |
Specifies how to send form-data. Overrides the forms action attribute. |
| formnovalidate |
formnovalidate |
If present, indicates that the form should not be validated when submitted. Overrides the forms action attribute. |
| formtarget |
_blank
_self
_parent
_top
framename |
Specifies where to open the action URL. Overrides the forms action attribute. |
| name |
button_name |
Specifies a unique name for the button |
| type |
button
reset
submit |
Defines the type of button |
| value |
some_value |
Specifies an initial value for the button. The value can be
changed by a script |
Standard Attributes
| class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title |
For a full description, go to Standard Attributes in HTML 5.
Event Attributes
| onabort, onbeforeunload, onblur, onchange, onclick,
oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave,
ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress,
onkeyup, onload, onmessage, onmousedown, onmousemove,
onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect,
onsubmit, onunload |
For a full description, go to Event Attributes in HTML 5.
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4000 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|