Creating the form tag

To create web page forms, you will need to use the <form> tag. The <form> tag is a two-sided tag, which means it start with <form> and ends with </form>. All of your form elements must be placed inside the opening form tag and the closing form tag. The <form> tag has three properties (or attributes) that control how and where the form is processed. Those properties are summarized in table 1.

Table 1 summary of form attributes
Property Description Value (s)
name allows you to identify different forms you may have on a page Defined by the web developer
method determines whether the form is used to send information to or bring information from the server. post - sends form to the server
get - brings information from the server
action Determines where the form is being sent for processing Determined by the web developer

The following, for example

<form name="Test" method="post" action="creating-web-page-forms.asp">

creates a form named Test, sets method to post, and sets the action to a file called creating-web-page-forms.asp. Let's go dicuss the details of this example.

The above code creates a form because we are using the <form> tag. Anytime we want to refer to this specific form, we will use the name "Test." Note the name property is necessary only if you have more than one form on a single web page. If you had more than one form on a single web page, by using the name attribute for each form to assign a different/unique value to each form will help the server to determine which specific form you are working with.

The method="post" states that we want to send the information to the server using the post method. Basically, the whole purpose of the post method is to determine whether or not you want to add the form data to the end of the URL. If you use the get method, the information that the user submits is added to the end of the URL. Suppose you are using the get method for a form to ask the user for his/her number of years of experience in HTML. Let's say the user enters or selects 5 years and submit the form. After the form is submitted, the URL will automatically change to something like

In other words, before the form is submitted, the URL of the web page would be but after the form is submitted it will change to The get is not desirable for situations where you are asking the user for his/her social security number or any other personal information as it will be visible in the URL. Depending on the form, the URL could become very long. There are, however, advantages of using the get method. First of all, once the user enters and submits the form, the user could repeatedly use (by saving the URL as favorites) the same URL without reentering the requested information. A typical example would be of finding driving directions on MapQuest or Yahoo! Maps.

In comparison, the post method does not add the information collected from the form to the end of the URL of the web page.

In the example, the action specifies that the form data should be sent to a file called creating-web-page-forms.asp. In this file, the form data will be processed (checked for validity, stored to a database, etc).