The form Tag

Welcome to our free HTML tutorial. This tutorial is based on Webucator's Introduction to HTML Training course.

Contact Us or call 1-877-932-8228
The form Tag

The form Tag

HTML forms are created using the <form> tag, which takes two main attributes: action and method.

The action specifies the URL of the page that processes the form. The method attribute has two possible values: post and get (default value). A form tag example is shown below:

<form>form method="post" action="">
	<!--form fields go here-->

Get vs. Post

The value of the method attribute determines how the form data will be passed to the server.


If get is used the data will be appended to the URL as part of a querystring. For example, if the form is filled out as follows:Order Form

When the user submitted the form, the URL for the new page would read (without the line breaks):

		requests=I+want+a+really+big+cone%21&discount=20%25&submit button=Place+Order

You'll notice the file name is followed by a question mark, which is followed by several name-value pairs (e.g., container=wafflecone) separated by ampersands (&).

The get method is commonly used by search engines, because it allows the resulting page to be bookmarked.


When post is used, the name-value pairs are not sent as part of the querystring. Instead they are sent behind the scenes. This has the advantage of keeping the values hidden from anyone looking over the user's shoulder. Two other advantages of the post method are:

  1. It allows for much more data to be submitted (i.e., larger forms).
  2. It allows for files to be uploaded to the server.

As a general rule, you should use post unless you want the user to be able to bookmark or share (e.g., via email) the resulting web page.


This tutorial is based on Webucator's Introduction to HTML Training Course. We also offer many other HTML Training courses. Sign up today to get help from a live instructor.