Report any bugs and Link not Found Contact Us Report!

How to Create a Form in HTML - Programming HTML

Element Form in HTML is useful for receiving input from the user. With the form, we can collect information or data from the user.


Element Form in HTML is useful for receiving input from the user. With the form, we can collect information or data from the user. An example of form, one of which is the registration form that exists when you create a Gmail account. You will be asked to enter some personal information such as first name, last name, username, password, etc. Then how to create HTML forms?

To create a form element we need 2 basic tags, namely:

1. <form> tag

Used to start creating a form. The <form> tag has several attributes but the attributes that are often used include:

"action" attribute is used to specify the address (URL) where to submit the form
"method" attribute is used to determine the HTTP method used when submitting a GET or POST form

2.<input> Tag

Used to specify the type of input you want to make. The <input> tag consists of several attributes, namely:
  1. Attribute “name” Specifies the name used to identify the form.
  2. Attribute "type" is used to determine what type of input you want to make, this attribute consists of several types, for example:
  • <input type="text"> is input that accepts text input.
  • <input type="password"> is input that accepts text as input but the inputted text will not be visible.
  • <input type="radio"> is input that is used to provide several options to the user.
  • <input type="checkbox"> is input in the form of a checkbox that can be checked or checked by the user
  • <input type="submit"> is used to display the button to process the form.
  • <input type="button"> is used the same as submit but is usually used with JavaScript or VBScript to generate an action.
  • <input type="image" src="url"> is used to change the submit button with an image.
  • <input type="reset"> is used to reset or delete all entries that have been filled in the form.

3.<button> tag

Is used to create a button to process the form which is more recommended than submitting input. the attribute used is the same as the input but there are only 3 types used in the attribute type, namely:
  • <button type="submit"></button>
  • <button type="button"></button>
  • <button type="reset"> </button>

4. <select> tag

Is used the same as <input type="radio"> to give the user choices but with a drop-down menu-like appearance. This <select> tag has an additional tag, namely the <option> tag which is used to enter the options of the choice.

Example HTML Form :

 <html>
   <head>
     <title>Registration form</title>
   </head>
<body>
        <fieldset>
            <legend>Registration form</legend>
            <form>
                  <label for="username">Username :</label>
                  <input type="text" name="name" id="username"> <br>
                  <label for="password">Password :</label>
                  <input type="password" name="password" d="password"> <br>
                  <label>Gender :</label>
                  <input type="radio" name="gender" value="gender1">Male <input type="radio" name="gender" value="gender2">Female <br>
                  <label>Hobby :</label> <input type="checkbox">Vlogger<input type="checkbox">Youtuber<input type="checkbox">Content Creator<br>
                  <label>Residence :</label>
                              <select>
                                           <optgroup label="United States">
                                           <option>New York</option>
                                           <option>Los Angeles</option>
                                           <option>
California</option>
                                           </optgroup>
                                           <optgroup label="United Kingkom">
                                           <option>London</option>
                                           <option>Manchester</option>
                                           <option>Liverpool</option>
                                           </optgroup>
                                           <optgroup label="Indonesia">
                                           <option>Jakarta</option>
                                           <option>Bandung</option>
                                           <option>Bali</option>
                                           </optgroup>
                            </select>
                  <br> 
              <button type="submit">Submit</button>
              </form>
         </fieldset>
</body>
</html>

Result :

  
   
     Registration form
   
   
        
Registration form


Male Female
VloggerYoutuberContent Creator


Conclusion

So HTML Form is a form used to create a page form, to make it required 2 basic tags, namely <form> and <input>, and has a lot of attributes that can be used.

Getting Info...

Post a Comment

AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.