Why do we use reset button in HTML forms?

The reset button is used to reset all the input fields in HTML forms. It gets added using the <input> tag attribute type.

The <input type="reset"> defines a reset button which resets all form values to its initial values.


<input type="reset">

Example 1

An example to implement the usage of reset button in HTML forms is given below −

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <form> Enter Name<br> <input type="text" name="Ename"> <br> Enter Age<br> <input type="text" name="Eage"> <br> Enter Address<br> <input type="text" name="Eaddress"> <br><br> <input type="reset" value="reset"> </form> </body> </html>

Example 2

You can try to run the following code to reset button in HTML forms −

<!DOCTYPE html> <html> <body> <form> Student Name:<br> <input type="text" name="sname"> <br> Student Subject:<br> <input type="text" name="ssubject"> <br> <input type="reset" value="reset"> </form> </body> </html>

Updated on: 19-Oct-2022


Kickstart Your Career

Get certified by completing the course

Get Started