HTML <button>
query_builder | Christopher PisaniThe HTML element <button> represents a clickable button, which can be used in forms or anywhere in a document that needs simple, standard button functionality.
This element can work for submitting and resetting the form, but it is advisable to use the <input> element for that job. Advantage of buttons vs input elements is that they can hold clickable images as well. The button element is also widely used in conjunction with Javascript language, to run custom scripts.
<button>Test Button</button>
Important Note :
It is inapproriate for other elements like <span>, <div> and <a> to be used instead of the element <button>.
Available Attributes
Attribute | Values | Functionality |
---|---|---|
autofocus | boolean | Will auto highlight the button when page loads |
disabled | boolean | Disables the button, actions linked to the button will not work |
form | The form's id | Specifies which form is part of |
formaction | url | Where the data is sent on submission |
formenctype | application/x-www-form-urlencoded multipart/form-data text/plain |
What data is to be used |
formmethod | GET POST |
How data is sent as |
formnovalidate | boolean | If form will be validated or not |
formtarget | url | where to display results after submitting |
name | text | name associated with the button |
type | button reset submit |
Button's behaviour |
value | text | default value for button |