The HTML <button> tag is used to create a button control.
Most of the times the <button> tag is used in conjunction with the <form> element but it can also be used as a standalone control.
The <button> tag defines a clickable button.
Inside the <button> texts or images can be inserted. This is the difference between this element and buttons created with the <input> element.
Required Attributes
Optional Attributes
- accesskey can be used to associate a particular keyboard shortcut to the element.
- tabindex can be used to specify where the element appears in the tab order of the page.
- disabled can be used to disable the button. It must be used in the format disabled="disabled".
- name can be used to associate a name to the button so that it can be processed by a form-handling script.
- type can be used to specify the button type. Values can be button (doesn't do anything), submit (default; submits the form when the button is selected) or reset (resets the form).
- value can be used to specify an initial value.
- Common attributes
Example
<button onclick="JavaScript:alert('Well done!')">Click Me!</button>
Changes in HTML5
- HTML5 has the following new attributes: autofocus, form, formaction, formenctype, formmethod, formnovalidate, and formtarget.
Related Tags