HTML form action Attribute

« Previous Tutorial Next Tutorial »

The action Attribute

The action attribute of the FORM tag provides the URL of the program (which is in the server) that receives the information from the form and processes it. This URL is also referred as form's action URL. Most of the servers keep these form processing programs in a bin known as Common Gateway Interface-binaries (cgi-bin)

HTML form action Attribute Example

Following is an example of using the action attribute in the FORM tag.

<FORM action="">

Here, the name of the program that handles the form is updated, which is placed in the CGI-BIN directory. This directory is placed in the domain


As already discussed, the enctype attribute is used to specify the format of the form's content at the time of submission. The action attribute is used to specify the address of the server to send the content of the form. And the method attribute is used to specify the name of the method using which the content is sent to the server.

Let's create a Web page say formaction.html to understand the use of action attribute. Here is the source code of formaction.html

	<title>HTML form action Attribute Example</title>
	<form action="action.asp" method="get" enctype="text/plain">
		First Name: <input type="text" name="first_name" /><br />
		Last Name:  <input type="text" name="last_name" /><br />		
		<input type="submit" value="Submit" />

Here, we have set the action attribute of the FORM tag to action.asp.

You also need to create an HTML page, named action.html to be redirected after submitting the form. Here is the source code for action.html file.

	<title>Form Submitted</title>
	<h2>The form is successfully submitted.</h2>
	<h2>Back to Tutorial</h2>
	<a href="/html/html-action-attribute.htm">HTML form action Attribute</a>

Here, we have included the link of HTML form action Attribute. You can exclude it.

When you open the formaction.html file, the output is displayed on a Web page, as shown in this figure.

html form action attribute

You need to enter your first and last name in the respective text boxes and click the Submit button as shown in this figure.

html action attribute

This submits the form and redirects you to the action.html page, as shown in this figure.

html form action

You can also try it with your own, just fill the form given below and click on the Submit button to watch the result.

First Name:
Last Name:

« Previous Tutorial Next Tutorial »


Quick Links
Signup - Login - Give Online Test