HTML Form Attributes

Here are some important attributes of <form> tag:

Form Method

Method attribute specifies how the form data is sent to the server. The possible values are:

  • Get: It sends the data as part of URL. The data included with URL can be seen by other people. GET method is default one by browser.
  • Post: It sends the data encoded in HTTP data stream. It is mostly used to send a large amount of data or in sensitive cases. Post method is more secure than GET.

Example

<!doctype html>  
<html>
 
    <head> 
        <title>Form Method</title> 
    </head>
  
    <body> 
        <form method="get">
          ....
        </form>
    </body>

</html>

Form Action

Action attribute specifies where the form data will be submitted. It is normally sent to a script on the server or submitted as email.

Example

<!doctype html>  
<html>
 
    <head> 
        <title>Form Action</title> 
    </head>
  
    <body> 
        <form method="get">
          ....
        </form>
    </body>

</html>

Form Example

<!doctype html>  
<html>
 
    <head> 
        <title>Form Method</title> 
    </head>
  
    <body> 
        <form action=”form.php” method="get">
          ....
        </form>
    </body>

</html>