HTML <button> Type Attribute

Introduction

In the HTML page, we can specify the button with the help of the button attribute value. It will be set in the web browser as a button element. The default types of <button> elements can vary from browser to browser.

Syntax for button type attribute:

We can specify the button type attribute with the help of the below syntax:

Attribute Values

Three types of attribute values are used in the button tag. With the help of this type of attribute value, we can specify the work of the button tag.

  • Submit: with the help of this attribute value, we can specify that it is a submit button. It is the default value for the submit button for all browsers except for Internet Explorer.
  • Button: with the help of this attribute value, we can specify that it is a clickable button. It is the default value for the Internet Explorer.
  • Reset: with the help of this attribute value, we can specify that it is a reset button. It is used to change the previous data from the form.

Let's take an example for each attribute value.

Example 1:

Output:

HTML Button Type

Explanation:

In the above code, we create a form. It will accept the data from the user. When the user clicks the submit button, all the values will be stored in the server.

Example 2:

Output:

HTML Button Type

Explanation:

In the above code, we create a form. It will accept the data from the user. When the user clicks the submit button, all the values will be stored in the server. When the user clicks the reset button, it will clear the whole page.

Example 3:

Output:

HTML Button Type

Explanation:

In the above code, we create a form. It will accept the data from the user. When the user clicks the submit button, all the values will be stored in the server. When the user clicks the reset button, it will clear the whole page. Also, we have created a button tag. Users can sign themselves on the webpage when they click on it.

Supported Browsers

The browsers supported by HTML <button> type attribute are listed below:

  • Google Chrome
  • Edge 12
  • Internet Explorer
  • Firefox
  • Safari
  • Opera