The button
tag defines an interactive element that performs an action when activated.
The type
attribute should always be specified, so the browser will know what type of button it is.
<button type="button">Click Me</button>
autofocus
Designates that a button should focus on page load.
disabled
Designates that a button should be disabled.
form
Tells the browser which form ID the the button belongs to.
formaction
Provides the URL to send the form data when a form is submitted and the button type="submit"
.
formenctype
Provides the method of encoding used (application/x-www-form-urlencoded
, multipart/form-data
, or text/plain
) for the form-data before sending it to a server. Only used when button type="submit"
.
formmethod
Designates which HTTP method to use (get
or post
) to send the form-data. Only used when button type="submit"
.
formnovalidate
Specifies to not validate the form-data when it is submitted. Only used when button type="submit"
.
formtarget
Designates where to open the form response after submission (_blank
, _self
, _parent
, or _top
). Only used when button type="submit"
.
name
Designates the button’s name.
type
Designates what type of button it is (button
, reset
, or submit
).
value
Designates the initial value for the button.
User-submitted codepen.io examples of <button>
↴
Submit a codepen.io link that demonstrates <button>
: