A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-action-attribute/ below:

HTML action Attribute - GeeksforGeeks

HTML action Attribute

Last Updated : 11 Jul, 2025

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>
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 Type Description Example Absolute URL Points to another website or domain. https://www.gfg.org/ Relative URL Refers to a file within the same website or domain. www.geeksforgeeks.org

More 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:

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>
Best Practices for HTML action Attribute

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4