Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Jul 1, 2022Updated Apr 4, 2023
Contribute to Docs

The <button> element represents a button meant to be clicked by the user.

While buttons are often associated with form submission, they can be used for any part of the page which needs an interface for user interaction.


<!-- Button content lives here -->

Opening and closing <button> tags wrap around a block of content. By default, it appears inline, like a <span> element, and is styled to appear consistent with buttons on the device it is viewed on.

It is possible for the content to be plain text or other HTML elements. This can include lists, paragraphs, or even images.


There are a large number of available attributes that provide extra meaning to the browser. A few of the common ones are shown below:

Attribute Data Type Description
autofocus Boolean Automatically makes the button focused on the page.
disabled Boolean Makes the button unusable.
type String Sets the intended behavior of the button, including:
  • submit: This button should submit the form it is a part of.
  • reset: This button should reset the values in the form it is a part of.
  • button: This button should neither submit nor reset the form it is a part of.


Suppose there is a form that needs both a submit and reset button, and that the submit button should have an image rather than text. It might be coded in the following way:

<head> </head>
<label>Your Name</label>
<input type="text" name="user_name" />
<!-- More form elements -->
<button type="reset">Reset Form</button>
<button type="submit"><img src="submit.png" alt="Submit Form" /></button>

Output of the button tag example

All contributors

Looking to contribute?

Learn HTML on Codecademy