HTML action Attribute Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 11 Likes Like Report The HTML action attribute is used to specify where the form data should be sent on submission. It allows the browser to send the data to the specified location, enabling server-side scripts to process the data and generate a response.Note: It can be used in the <form> element. Syntax:<form action="URL"> HTML <html> <body> <form action="/submit-form" method="post"> <label for="username">Username:</label> <input type="text" id="username" name="username" required> <br><br> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <br><br> <input type="submit" value="Submit"> </form> </body> </html> The <form> element's action attribute is set to "/submit-form", indicating that when the form is submitted, the data will be sent to the /submit-form URL for processing.The method attribute is set to "post", specifying that the form data should be sent using the HTTP POST method.Attribute Values: URL: It is used to specify the URL of the document where the data is to be sent after the submission of the form. The possible values of the URL are: URL TypeDescriptionExampleAbsolute URLPoints to another website or domain.https://www.gfg.org/Relative URLRefers to a file within the same website or domain.www.geeksforgeeks.orgMore Examples of HTML Action Attribute Submitting Form Data to a Server-Side Script HTML <html> <body> <form action="https://www.example.com/process-form" method="post"> <label for="name">Name:</label> <input type="text" id="name" name="name" required> <br><br> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <br><br> <input type="submit" value="Submit"> </form> </body> </html> In this example:The action attribute is set to "https://www.example.com/process-form", indicating that the form data will be sent to this URL for processing upon submission.The method attribute is set to "post", specifying that the form data should be sent using the HTTP POST method.Using a Relative URL in the action Attribute HTML <html> <body> <form action="/submit-form" method="get"> <label for="search">Search:</label> <input type="text" id="search" name="query" required> <br><br> <input type="submit" value="Search"> </form> </body> </html> The action attribute is set to "/submit-form", a relative URL pointing to a resource within the same domain. This means the form data will be sent to the /submit-form path on the current website.The method attribute is set to "get", indicating that the form data will be appended to the URL as query parameters.Best Practices for HTML action AttributeSpecify a Valid URL: Ensure the action attribute points to a valid server endpoint that can process the submitted form data. Use Appropriate HTTP Methods: Combine the action attribute with the method attribute, setting method="post" for sensitive data submissions and method="get" for idempotent requests like search queries. Create Quiz Comment M manaschhabra2 Follow 11 Improve M manaschhabra2 Follow 11 Improve Article Tags : Web Technologies HTML HTML-Attributes Explore HTML BasicsHTML Introduction4 min readHTML Editors4 min readHTML Basics7 min readStructure & ElementsHTML Elements4 min readHTML Attributes7 min readHTML Headings3 min readHTML Paragraphs3 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks2 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables9 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms4 min readHTML5 Semantics5 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List5 min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like