HTML <button> type Attribute

HTMLWeb DevelopmentFront End Technology

The type attribute of the <button> element is used to set type of the button. Following is the syntax −

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

Above, we have shown the different types set for the button element i.e.: submit −

  • button: A clickable button
  • submit: Submit button (submits form-data)
  • reset: It is a reset button to reset it to the initial value.

Let us now see an example to implement the type attribute of the button element in HTML −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
<h2>Investor Information</h2>
<p>Give the information about the investor interested in funding:</p>
<form action="" method="get">
   ID: <input type="number"><br>
   Investor: <input type="text"><br>
   Funds: <input type="number"><br>
   Email: <input type="email"><br>
   DOB: <input type="date"><br><br>
   <button type="submit" value="Submit">Submit</button>
   <button type="reset" value="Reset">Reset</button>
</form>
</body>
</html>

This will produce the following output with submit and reset button −

In the above example, we have created a form with form elements and buttons −

<form action="" method="get">
   ID: <input type="number"><br>
   Investor: <input type="text"><br>
   Funds: <input type="number"><br>
   Email: <input type="email"><br>
   DOB: <input type="date"><br><br>
   <button type="submit" value="Submit">Submit</button>
   <button type="reset" value="Reset">Reset</button>
</form>

The buttons type we have set to create a submit as well another button, which would be for reset −

<button type="submit" value="Submit">
   Submit
</button>
<button type="reset" value="Reset">
   Reset
</button>
raja
Published on 20-Jun-2019 10:42:34
Advertisements