How to create a simple form using HTML?

From is a necessary element in any website or blog. Mostly they are used to take user information for any of the purposes like logging into the user account, creating user account, allowing to subscribe malling list, allowing users to submit comments and allowing users to contact website admin, support or sales team.

Here I am going to describe "How to create a simple form using HTML" step by step with describing what is a form and what elements are used to create HTML form along with complete HTML code for a form.

A form is an area that contain form elements. You must set up a form before adding in run to the web page. To setup a form, you need to specify two important information Method and Action.

Method is a property tells the form how to transfer the data to the form processor. The value for method can be 'post' or 'get' In post method you are just posting information and method get means that you are just going to get another page. In almost all of the form post method is used.

Action property tells what action the form should take when the user presses the submit button. Action is the URL to which you are posting the information.

We have to use different HTML tags to create a form. The most commonly used HTML tags to create a form are listed below.


Different Tags for HTML Form


Tag: The most form tag is tag. The type of INPUT is specified with the TYPE attribute. This tag doesn't have its ending tag. The most commonly used INPUT types are listed below:

TEXT: It is used for plain type of text input. The attributes used in this type are NAME, VALUE, SIZE and MAXLENGTH.

Example:


PASSWORD: It is used for password type of text input. The attributes used in this type are NAME, VALUE, SIZE and MAXLENGTH.

Example:


RADIO: It is used for single choice input system. The attributes used in this type are NAME, VALUE and CHECKED

Example:


CHECKBOX: It is used for multiple choice input system. The attributes used in this type are NAME and VALUE.

Example:


RESET: It is used to reset values entered in a form. Value is the attribute of RESET type of INPUT. 
Example:


SUBMIT: It is used to submit values entered in a form. Value is the attribute of SUBMIT type of INPUT.

Example:





Subscription Form

Subscription Form





First Name:


Last Name:


Password:


Retype Password:


Email:


Sex:MaleFemale


Write About You:


Your Academic Level:


Select your Topic to Subscribe:
Multiple Choice Questions

IT Tutorials

Programming Guide







Preview of the above HTML Code

 

Subscription Form


First Name:

Last Name:

Password:

Retype Password:

Email:

Sex:MaleFemale

Write About You:

Your Academic Level:

Select your Topic to Subscribe:
Multiple Choice Questions
IT Tutorials
Programming Guide



Here I have posted the HTML codes for sample only. You can customize this form according to your requirement. You can extract and use any element to create your own form.



Related Posts: