HTML action Attribute
Last Updated :
05 Jan, 2024
The HTML action Attribute is used to specify where the form data is to be sent to the server after the submission of the form. When a user submits a form, the browser sends the data to the specified URL, allowing server-side scripts to handle the information and generate a response.
Note: It can be used in the <form> element.
Syntax:
<form action="URL">
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:
|
It points to another website link. For Example: www.gfg.org
|
|
It is used to point to a file within a webpage. For Example: www.geeksforgeeks.org
|
Example : This Example illustrates the use of action attribute in an HTML document.
HTML
<!DOCTYPE html>
<html>
<head>
<title>HTML action Attribute</title>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>HTML action Attribute</h2>
<form action="test.php" method="post" id="users">
<label for="username">Username:</label>
<input type="text" name="name" id="username"><br><br>
<label for="password">Password:</label>
<input type="password" name="pass" id="password">
</form>
<br>
<button onclick="myGeeks()">Submit</button><br><br>
<b>
After Submitting the form-data will sent
to the "test.php" page on the server.
</b>
</body>
</html>
|
Output:

Supported Browsers:
- Google Chrome 1
- Edge 12
- Firefox 1
- Opera 15
- Safari 4
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...