- HTML Basics
- HTML Home
- HTML Basics
- HTML Document Structure
- HTML Data Types
- HTML Attributes
- HTML Fonts
- HTML Headings
- HTML Character Entities
- HTML Horizontal Line
- HTML Line Break
- HTML Paragraph
- HTML Citation Definition
- HTML Quotations
- HTML Comments
- HTML Styles
- HTML Formatting
- HTML CSS
- HTML Tags
- HTML Basic Tags
- HTML All Tags
- HTML Root Tags
- HTML Metadata Tags
- HTML Section Tags
- HTML Head Heading Tags
- HTML Flow Tags
- HTML Phrasing Tags
- HTML Embedded Tags
- HTML Interactive Tags
- HTML Meta Tags
- HTML Texts
- HTML Text Formatting
- HTML Physical Style Text
- HTML Logical Style Text
- HTML Organizing Text
- HTML Arranging Text
- HTML Displaying Lists
- HTML List
- HTML Links Tables
- HTML Links URLs
- HTML Links
- HTML URL Encode
- HTML Tables
- HTML Images Colors
- HTML Images Colors
- HTML Images
- HTML Color Codes
- HTML Canvas
- HTML Backgrounds
- HTML Forms
- HTML Forms
- HTML Form Tag
- HTML Input Tag
- HTML Button Tag
- HTML Multiple-Choice
- HTML Select Tag
- HTML Option Tag
- HTML Optgroup Tag
- HTML Textarea Label
- HTML Fieldset Legend
- HTML Datalist Tag
- HTML Keygen Tag
- HTML Output Tag
- HTML Progress Tag
- HTML Meter Tag
- HTML Submit Form
- HTML enctype Attribute
- HTML action Attribute
- HTML Method Attribute
- HTML Get Method
- HTML Post Method
- HTML Interactive
- HTML Interactive Web
- HTML Details Summary
- HTML Menu Tag
- HTML Command Tag
- HTML KBD Tag
- HTML Time Tag
- HTML Multimedia
- HTML Multimedia
- HTML Multimedia Tags
- HTML Audio Video
- HTML Embedded Multimedia
- HTML EMBED Tag
- HTML OBJECT Tag
- HTML FIGURE FIGCAPTION
- HTML Advance
- HTML Blocks
- HTML Classes
- HTML Iframes
- HTML JavaScript
- HTML Layouts
- HTML Responsive
- HTML Test
- HTML Online Test
- Give Online Test
- All Test List
HTML form 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="http://codescracker.com/cgi-bin/update">
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 codescracker.com domain
Example
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
<!DOCTYPE HTML> <html> <head> <title>HTML form action Attribute Example</title> </head> <body> <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" /> </form> </body> </html>
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.
<!DOCTYPE HTML> <html> <head> <title>Form Submitted</title> </head> <body> <h2>The form is successfully submitted.</h2> <hr/> <h2>Back to Tutorial</h2> <a href="/html/html-action-attribute.htm">HTML form action Attribute</a> </body> </html>
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.

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

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

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