Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to HTML Notes
Topic #730

form action

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

ValueBehavior
A relative pathSubmits within the current site — the most common case
An absolute URLSubmits 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 action at 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 action submits to the exact current URL, which may not be what's actually intended

Best Practices

  • Always set action explicitly rather than relying on the implicit same-page fallback
  • Verify the destination endpoint genuinely accepts the form's method and 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

  1. Build a form with an explicit relative action.
  2. Research the formaction attribute on <button> and explain what problem it solves.

Related HTML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →