Form Action in HTML

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

Overview

In this article, you'll see how the action attribute is used with the form element and how to use form action in HTML. As you are familiar with the forms in HTML, we'll not cover forms in detail in this section. Refer here to learn more about forms in detail. In brief, HTML forms are used to collect different kinds of data, such as names, contact details, email addresses, etc., from the users.

Forms contain special elements called controls like submit buttons, checkboxes, etc. Similarly, an attribute named action on the form tag specifies where to send the form data. The form action in HTML is discussed along with the examples in this section.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

HTML Form Action Attribute

Forms are used to accept the data from the user, and a form is useless unless some kind of processing takes place after submitting the form. To do this processing, there is an attribute called the action attribute, which specifies where to send the form data when submitted. In short, the action attribute or form action in HTML is used to inform the browser what page to call when the submit button is pressed.

The form data is mostly sent to a server-side handler, but it can also be sent to the JavaScript on the client. Let's see how you can use the form action in HTML while creating forms.

Syntax:

Value:

  • URL: This is used to define the link or URL where we want to send the form data once the form is submitted. The URL can be anything like a URL to a document on the same server or an entirely different server, for example, a form-handling service.

Example

Consider an example below which explains how you can use the form action in HTML while developing web applications.

Output

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Is The Action Attribute Required?

The action attribute was widely used in HTML4. Nowadays, in HTML5, you are not required to specify the action attribute. If you already have a form tag without an action attribute, then the data entered by the user will be sent to its own page i.e. in Single Page Application (SPA), you might want to process the form data using JavaScript, or you want another framework to process the data. Hence, in such cases, the action attribute is not required.

As Single Page Applications continue to grow in recent times, the data processing from the form is done using JavaScript. Or the data can be processed using other frameworks like React, Angular, etc.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Browser Support

  • Chrome 1.0 -- Sep 2008

  • Firefox 1.0 -- Sep 2002

  • IE/Edge 1.0 -- Aug 1995

  • Opera 1.0 -- Jan 2006

  • Safari 1.0 -- Jan 2003

Conclusion

  • The HTML action attribute defines what happens when a form is submitted.
  • The form action (attribute) in HTML accepts an argument.
  • The value of the URL should be the URL.
  • A detailed example is given to explain the form action in HTML.
  • The action attribute was used in HTML4, but in HTML5, the action attribute is `no longer required.
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more