The action attribute on <form> tells the browser exactly where to send the submitted data — the destination URL that processes it.
Syntax
<form action="/process-signup" method="post">
Basic Example
<form action="/newsletter-subscribe" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
<button type="submit">Subscribe</button>
</form>
Browser output: submitting this form sends its data to /newsletter-subscribe, which is expected to be a real server-side endpoint capable of receiving and processing it.
How It Works
action can be a relative URL (like /submit), an absolute URL (linking to an entirely different domain, like a third-party form service), or omitted entirely — in which case the form submits back to the current page's own URL.
Important Attributes
| Value | Behavior |
|---|---|
| A relative path | Submits within the current site — the most common case |
| An absolute URL | Submits to a different domain entirely, like a third-party service |
| (omitted) | Submits back to the exact current page URL |
Real-World Example
<form action="https://formspree.io/f/your-form-id" method="post">
<label for="message">Message</label>
<textarea id="message" name="message"></textarea>
<button type="submit">Send</button>
</form>
A form submitting directly to a third-party form-handling service via an absolute URL — a common pattern for static sites with no backend of their own.
Common Mistakes
- Pointing
actionat a URL that doesn't actually exist or doesn't accept the form's HTTP method, resulting in a broken submission - Forgetting that an omitted
actionsubmits to the exact current URL, which may not be what's actually intended
Best Practices
- Always set
actionexplicitly rather than relying on the implicit same-page fallback - Verify the destination endpoint genuinely accepts the form's
methodand expected field names
Accessibility Considerations
No direct accessibility impact — this attribute is purely about where data is routed.
SEO Considerations
No direct ranking effect.
Browser & Modern HTML Notes
A <button type="submit" formaction="..."></button> can override a form's action for that specific button alone — useful when one form needs multiple possible submission destinations (like "Save Draft" vs "Publish").
Mini Practice
- Build a form with an explicit relative
action. - Research the
formactionattribute on<button>and explain what problem it solves.