×

HTML Reset Button

The HTML reset button is used to reset all values in the form. It clears all input fields.

Reset is the value of the type attribute of the button element. The HTML reset button resets all inputs in the form to initial values.

Syntax:

<button type="reset" value="submit">Reset</button> 

Examples of the HTML Reset Button:

Example 1:

Following is the code of the form with submit button and reset buttons. We are using CSS to make the form attractive.

<!DOCTYPE html>  
<html>  
<head>  
<meta name="viewport" content="width=device-width, initial-scale=1">  
<title>  
Example 1 of Reset Button  
</title>  
<style>  
  
body {  
font-family: Calibri, Helvetica, sans-serif;  
background-color: rgb(163, 34, 152);  
color:  white ;
}   


input[type=text] {  
  width: 100%;  
  display: inline-block;  
  margin: 3px 0 20px 0;  
  padding: 9px; 
  background: #e7cece; 
  border: none;  
}  
input[type=text]:focus {  
background-color: rgb(242, 225, 192);  
outline: none;  
}  
 div {  
            padding: 10px 0;  
}       
 
button {  
  background-color: #0c344c;
  margin: 5px 0;  
  color: white; 
  cursor: pointer;  
  width: 100%;
  padding: 14px 18px;   
  border: none;  
  opacity: 0.9;  
}  
button:hover {  
opacity: 1;  
}  


</style>  
</head>  
<body>  
<form>  
<div class="container">  
<center>  <h1> Form </h1> </center>  
<label for="fn"> First Name </label>   
<input type="text" id="fn" name="First Name" placeholder= "First Name" size="15" required />   
<label for="mn"> Middle Name: </label>   
<input type="text" id="mn" name="Middle Name" placeholder="Middle Name" size="15" required />   
<label for="ln"> Last Name: </label>    
<input type="text" id="ln" name="Last Name" placeholder="Last Name" size="15"required />   
  
<label>   
Gender :  
</label><br>  
<input type="radio" value="Male" name="gender" checked > Male   
<input type="radio" value="Female" name="gender"> Female   
<input type="radio" value="Other" name="gender"> Other  
  <br> <br>
<label for="phone">   
Phone :  
</label>  
<input type="text" name="Phone Number" placeholder="Country Code"  value="+91" size="2"/>   
  
<label for="email">   
Email  
</label>  
<input type="text" id="email" placeholder="Enter Email"  name="email" required>  
<button type="submit" value="submit"> Submit </button>
<button type="reset" value="reset"> Reset </button>  
</form>  
</body>  
</html>

Output:

The output displays a form with a submit button and a reset button; when you click the reset button, all the values in the form are cleared.

HTML Reset Button

Example 2:

We are building a responsive registration form using HTML and CSS with submit and reset buttons.

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>


    <title>Example 2 of Reset Button</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
     <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif,sans-serif;
  box-sizing: border-box;
}
body{
  height: 100vh;
  justify-content: center;
  display: flex;
  align-items: center;
  padding: 9px;
  background: linear-gradient(135deg, #f8e621, #e64a08);
}
.container{
  max-width: 650px;
  width: 100%;
  background-color: rgb(252, 233, 233);
  border-radius: 3px;
  padding: 22px 48px;
  box-shadow: 0 3px 9px rgba(64, 59, 59, 0.15);
}
.container .title{
  font-weight: 450;
  font-size: 22px;
  position: relative;
}
.content form .user-details{
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin: 20px 0 12px 0;
}
form .user-details .input-box{
  width: calc(100% / 2 - 20px);
  margin-bottom: 14px;
}
form .input-box span.details{
  display: block;
  margin-bottom: 4px;
  font-weight: 450;
}
.user-details .input-box input{
  height: 44px;
  width: 100%;
  font-size: 14px;
  padding-left: 14px;
  border-radius: 4px;
  border-bottom-width: 2px;
  border: 1px solid rgb(218, 214, 214);
  outline: none;
  transition: all 0.3s ease;
}
.user-details .input-box input:focus,
.user-details .input-box input:valid{
  border-color: #e64a08;
}
 form .gender-details .gender-title{
  font-size: 18px;
  font-weight: 450;
 }
 form .category{
   display: flex;
   margin: 12px 0 ;
   width: 85%;
   justify-content: space-between;
 }
 form .category label{
   display: flex;
   cursor: pointer;
   align-items: center;
 }
 form .category label .dot{
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #f09191;
  border: 4px solid transparent;
  margin-right: 10px;
  transition: all 0.3s ease;
}
 #gender1:checked ~ .category label .one,
 #gender2:checked ~ .category label .two,
 #gender3-:checked ~ .category label .three{
   background:#ea6523; 
  border-color: #8a8484;


 }
 form input[type="radio"]{
   display: none;
 }
 form .button{
   height: 45px;
   margin: 35px 0
 }
 form .button input{
   width: 100%;
   height: 65%;
   border: none;
   border-radius: 4px;
   color: rgb(244, 232, 232);
   font-weight: 450;
   font-size: 15px;
   cursor: pointer;
   letter-spacing: 1px;
   background: linear-gradient(135deg, #f8e621, #e64a08);
   transition: all 0.3s ease;
  }
 form .button input:hover{
  background: linear-gradient(-135deg, #f8e621, #e64a08);
  }
 @media(max-width: 550px){
 .container{
  max-width: 100%;
}
form .user-details .input-box{
  width: 100%;
  margin-bottom: 12px;
  }
  form .category{
    width: 100%;
  }
  .content form .user-details{
    overflow-y: scroll;
    max-height: 300px;


  }
  .user-details::-webkit-scrollbar{
    width: 4px;
  }
  }
  @media(max-width: 459px){
  .container .content .category{
    flex-direction: column;
  }
}
</style>


   </head>
<body>
  <div class="container">
    <div class="title"> Registration Form </div>
    <div class="content">
      <form action="#">
        <div class="user-details">
          <div class="input-box">
            <span class="details"> Full Name </span>
            <input type="text" placeholder="Enter Your Name" required>
          </div>
          <div class="input-box">
            <span class="details"> User Name </span>
            <input type="text" placeholder="Enter Username" required>
          </div>
          <div class="input-box">
            <span class="details"> Email </span>
            <input type="text" placeholder="Enter Your Email" required>
          </div>
          <div class="input-box">
            <span class="details"> Phone Number </span>
            <input type="text" placeholder="Enter Your Phone Number" required>
          </div>
          <div class="input-box">
            <span class="details"> Password </span>
            <input type="text" placeholder="Enter Your Password" required>
          </div>
          <div class="input-box">
            <span class="details"> Confirm Password </span>
            <input type="text" placeholder="Confirm Password" required>
          </div>
        </div>
        <div class="gender-details">
          <input type="radio" name="gender" id="gender1">
          <input type="radio" name="gender" id="gender2">
          <input type="radio" name="gender" id="gender3">
          <span class="gender-title"> Gender </span>
          <div class="category">
            <label for="gender1">
            <span class="dot one"></span>
            <span class="gender"> Male </span>
          </label>
          <label for="gender2">
            <span class="dot two"></span>
            <span class="gender"> Female </span>
          </label>
          <label for="gender3">
            <span class="dot three"></span>
            <span class="gender"> Prefer not to say </span>
            </label>
          </div>
        </div>
        <div class="button">
          <input type="submit" value="Register"> <br> <br>
          <input type="reset" value="Reset">
        </div>
      </form>
    </div>
  </div>


</body>
</html>

The output shows the responsive registration form. When you click the reset button, all the input fields become empty.

HTML Reset Button

You can see the responsiveness of the form in the output. When you change screen size from max to min, all the input fields in the form are stacked on each other, as shown below:

HTML Reset Button

The above examples show how to add the reset button in the form. It is recommended to avoid using the reset button because if the user accidentally clicks on the reset button, all the data is deleted, and the user will get frustrated.

Browser Support:

It supports the following browsers:

  • Google Chrome
  • Internet Explorer
  • Opera
  • Mozilla Firefox
  • Safari

Related Topics

HTML <strike> tag

The HTML <strike> tag is used to specifies strikethrough text. The tag is deprecated now and <del> tag is used in HTML files instead of it. All the global and...

2 minutes read.

HTML Code Tag

The code tag in HTML is a phrase tag used to insert a piece of computer programming code. In HTML there is a separate tag named as <code> tag. Sometimes,...

3 minutes read.

HTML <source> tag

For media attributes, such as <video> tag, <audio> tag, and <picture> tag, we use the <source> tag in html for adding such type of multiple media html elements in our...

4 minutes read.

HTML City tag

HTML <City> tag HTML < cite > tag specifies a citation, a reference or title to a creative work, quoted content, books, websites, a research paper, a blog post, a painting,...

3 minutes read.

HTML <style> tag

The section of information that we want to style is contained in html style tag. It includes CSS, which is used to design the text and images in the web page. Syntax: <head> <title>…………....

3 minutes read.

HTML Form Action

The <form> tag has an attribute named action that contains a URL. The HTML action attribute defines the webpage URL on which you want to send the data after submitting...

4 minutes read.

HTML 5 Tutorial

What is HTML5? HTML5 is a programming language which stands for the acronym Hyper Text Markup Language 5. It is program that enables the appearance of web pages to be changed, as well as changes...

5 minutes read.

HTML <table> tag

The Table element If we want to show the data and information in a two-dimensional table with rows and columns, then we can achieve this by using the HTML element <table>. Syntax: <body> <table> <thead> <tr> <thcolspan="#">………….</th> </tr> </thead> <tbody> <tr> <td>……….</td> <td>……….</td> </tr> </tbody> </table> </body> Example: <!DOCTYPE...

9 minutes read.

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.

HTML Id Attribute

The HTML id attribute represents the unique identifier for an element of the HTML document. Each element has its unique identifier. The id attribute is a global attribute that can be...

12 minutes read.

HTML Date

The input element in HTML has several attributes. One of its attributes is the type attribute which creates a calendar in an order that a user can select a date...

5 minutes read.

HTML Images

HTML has <img> tag to display image on the web pages or web application. This tag is an empty tag i.e. we don't have to close this tag while using. SYNTAX: <img src="source address" attributes="alt, height, width"> Example: <html>   <body>   <center>Image tag Example</center>   <img src="https://www.tutorialandexample.com/resources/images/favicon.png"    alt="tutorialandexample"/>   </body>   </html> Output: Image...

1 minute read.

HTML <u> tag

Underline Element/Tag: The u tag in html is used to specify the important text or phrase by underline. In earlier HTML versions, this element was known as the "Underline" element, and...

5 minutes read.

HTML5 Attribute

HTML Attribute HTML attributes are special words that provide additional information about the HTML element or attributes.The element or tags have attributes, which define the element's behavior.It also adds attributes with a start...

3 minutes read.

Html Wbr Tag

The Line Break Opportunity element A word break opportunity is a place in text from where the browser breaks a line. This opportunity is represented by the element wbr in the...

2 minutes read.

HTML Lists

HTML List HTML lists are used to specify data sets. All lists can include one or more elements from the list. HTML lists are available in three different types: Ordered List or...

4 minutes read.

Responsive HTML5 and CSS3 Tutorial

Introduction to HTML5 Tutorial HTML5 is the latest and upgraded version of HTML. HTML is a hypertext markup language. Technically, it is not a programming language. It is a markup language. HTML...

17 minutes read.

HTML Charsets

In this tutorial, we are going to discuss about the charsets in the HTML. The letters, numbers, and several other symbols are shown correctly by the web browser. All of this...

2 minutes read.

Html <colgroup> Tag

A HTML table's column group is specified by the "colgroup" tag. If you want to apply various properties to one or more <col> elements in an HTML table, then you...

4 minutes read.

HTML Ordered List

We use <ol> tag to make an ordered list in html. An ordered list is made to make a list of items in ordered form, ordered list can be either...

3 minutes read.