References

Beginner-friendly references for web development, with live, editable examples.

The HTML action attribute

Attribute All modern browsers Updated
Quick answer

The HTML action attribute specifies the URL that processes the form submission. It is used on the <form> element.

Overview

The action attribute sets the URL a form submits to. It is used on the <form> element.

It is a <form>-level attribute that controls how the form is submitted — where the data goes, the HTTP method, how it is encoded, and whether the browser validates first.

Syntax

<form action="/submit" method="post"> … </form>

Values

Value
A URL.

Best practices

  • Use method="post" for submissions that change data and method="get" for searches and filters.
  • Set enctype="multipart/form-data" when the form uploads files.
  • Prefer native validation over novalidate; only skip validation deliberately.
  • Always process and re-validate the submission on the server.

Frequently asked questions

What does the action attribute do?
Sets the URL a form submits to.
What is the difference between GET and POST?
GET appends the data to the URL (good for searches and bookmarkable results); POST sends it in the request body (used for actions that change data).
How do I let a form upload files?
Set method="post" and enctype="multipart/form-data" on the <form>.
Which elements use the action attribute?
It is an element-specific attribute, used on the <form> element.