CodingBanana
CodingBanana
HTML Basics

The action Attribute

5 min read📖 Beginner

So far every form you have written looks like this.

And that works fine for practicing. But if you ever peek at the source code of a real website and look at their forms, you will almost always see something like this instead.

That action attribute is new. So what does it do?

What action Actually Means

When a user fills out your form and clicks the submit button, the browser has to do something with all that information. The name they typed, the email they entered, the message they wrote. It has to go somewhere.

The action attribute is where you tell the browser exactly where to send it.

Think of it like writing an address on an envelope. The form is the envelope. The data inside is the letter. The action is the address on the front that tells the post office where to deliver it.

When the user clicks Send in this example, the browser takes everything the user filled in and sends it off to /submit. That destination could be a page on your website, a file on your server, or a script written in a language like PHP or Python that processes the data and does something useful with it, like saving it to a database or sending you an email notification.

You Do Not Need a Backend to Learn Forms

Here is something that trips up a lot of beginners. They see action and think they need a whole server set up before they can even practice building forms. That is not true at all.

If you are still learning and you do not have a backend yet, you can do either of these and your form will work perfectly fine for practice purposes.

Both of these just tell the browser not to send the data anywhere in particular. Your form will still look right, your validation will still run, and you can test everything without needing a database or a server. A lot of real front-end developers work this way for a long time before they ever touch a backend.

A Neat Little Trick for Testing

There is a free service called Formspree that a lot of developers use when they want to see their form actually do something without building a backend. You put their URL in your action and they handle the rest, forwarding the submission straight to your email.

You do not need to worry about setting this up right now. Just know it exists for when you want to see a real form submission happen on a real project without writing any server code.

The Short Version

The action attribute tells the browser where to send the form data when the user submits. No action means the data does not go anywhere, which is perfectly fine while you are learning. When you eventually connect your form to a real backend, this is the attribute you will fill in to make that connection happen.

Up next you will meet the method attribute, which is the other half of this picture. It controls not where the data goes but how it travels.

Have anything to say about this lesson?

Your feedback helps improve these tutorials. If something was confusing or missing, let us know.

We don't currently reply to feedback — but if we add that feature in the future, we'll reach out to you.