Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

HTML <button> type Attribute

The type attribute on a <button> tag specifies the type of button to create.

Options are: button, submit, and reset.

When clicked, each button type has its own behavior.

Example

#

A type attribute on a <button>.
The attribute specifies the button is a submit button.

<form action="/tutorial/action.html">
  <input type="text" name="email" placeholder="Enter your email">

  <button type="submit">Submit</button>
</form>

Using type

The type attribute specifies the button type and associated behavior.

If this attribute is not set, most browsers will treat a button as a submit button.

For this reason, always specify the type on a button element.


Syntax

<button type="button | submit | reset">

Values

#

Value Description
button A clickable button. Useful for executing custom client or server-side code.
submit A submit button that sends form-data to the server.
reset A button that clears all input controls in a form to their original values.

More Examples

This form has two button types:

  • A submit button that submits the form data.
  • A reset button that clears the email input field to its initial value (in this case blank).
<form action="/tutorial/action.html">
  <input type="text" name="email" placeholder="Enter your email">

  <button type="submit">Submit</button>
  <button type="reset">Reset</button>
</form>

Browser support

Here is when type support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <button>
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

Guides