Computer >> Computer tutorials >  >> Programming >> HTML

How do we reset all the input fields in HTML forms?


Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.

The <input> tag helps you to take user input using the type attribute. To clear all the input in an HTML form, use the <input> tag with the type attribute as reset.

How do we reset all the input fields in HTML forms?

Example

You can try to run the following code to reset input fields in HTML −

<!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>