1. Home
  2. Computing & Technology
  3. Web Design / HTML

The Method Attribute of the <form> Tag

HTML Forms Tutorial

By Jennifer Kyrnin, About.com

The method attribute tells the server how to submit the form information. There are two methods, GET and POST. The default method is GET.

GET
This sends the form information included in the URL. The get method sends the information to the server in one step. It is best used for forms where the information is not secure (as it can be seen in the URL), and the amount of information passed is small. Get requests are useful if you want to call a CGI from a link.

<form method="get" action="">

When to use the get method:

  • Short forms, with only 1 or 2 input fields
  • Forms with primarily select, radio, and checkbox fields
  • When the form needs to be called from a link
  • For mailto forms

POST
This sends the form information in the HTTP environment. It is a little more secure, in that your readers can't see it directly (although it is sent in clear text, so it can be "hijacked"). The post method sends the data to the server in two steps. First the browser contacts the server and after the contact is made, it sends the information. It is best used when you have a lot of information to pass (either textareas, or just a lot of fields.)

<form method="post" action="">

When to use the post method:

  • Longer forms, more than 3 input fields
  • Forms with large textarea fields
  • Forms where security is more important (but if security is paramount, use a secure server too)

Part 6 of the HTML Forms Tutorial: Mailto Forms
Get your forms to do something - send the results by email.

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

©2008 About.com, a part of The New York Times Company.

All rights reserved.