HTML Tag Reference - HTML tag <button>
<button>
performs a similar function to
the <input type="submit">
and
<input type="button">
elements.
<button> provides richer rendering capabilities.
Browser compatibility
|
|
|
|
|
|
<button> |
Yes |
Yes |
Yes |
Yes |
Yes |
What's new in HTML5
HTML5 has the following new attributes:
autofocus,
form,
formaction,
formenctype,
formmethod,
formnovalidate,
formtarget
Attribute
- autofocus
- Value
autofocus
tells browser to auto focus button automatically when the page loads
- disabled
- Value
disabled
diables a button
- form
- Value should be form id which sets owner forms of the button
- formaction
- Set URL to send the form-data when submitting form. Only for type="submit".
- formenctype
- Possible values:application/x-www-form-urlencoded,multipart/form-data,text/plain.
Set how to encode form-data before sending it to a server. Only valid for type="submit"
- formmethod
- Possible value:get|post.
Set which HTTP method to use to send the form-data. Only valid for type="submit"
- formnovalidate
- Set not to validate the form-data on submission. Only for type="submit"
- formtarget
- Possible value:_blank|_self|_parent|_top|framename.
Set where to display the response after submitting. Only for type="submit"
- name
- Set a name for the button
- type
- Possible value: button|reset|submit. Set the type of button.
- value
- Set an initial value for the button
Global Attributes
The <button> tag supports the Global Attributes in HTML.
Event Attributes
The <button> tag supports the Event Attributes in HTML.
Default CSS Settings
None.
Example
A demo showing how to use <button> tag.
<html>
<body>
<button type="button" id="myButton">
This is the button's label
</button>
</body>
</html>
Click to view the demo