Open In App

How to set the Method Attribute for the Form Submission in HTML ?

The method of form submission in HTML is set using the “method” attribute within the <form> tag. The “method” attribute specifies the HTTP method used when submitting form data to the server. There are two commonly used methods: “GET” and “POST”.

Syntax

<form method="GET/POST" action="URL">
<!-- Form fields -->
</form>

The table below illustrates the HTTP Methods alongside their descriptions.



HTTP Method Description
GET Sends form data as part of the URL query string. Suitable for submitting small amounts of data or retrieving data from the server.
POST Sends form data in the body of the HTTP request. Suitable for submitting large amounts of data or sensitive information securely.

Methods

Syntax

<form method="GET" action="submit.php">
<!-- Form fields -->
</form>

Syntax



<form method="POST" action="submit.php">
<!-- Form fields -->
</form>

Note: The choice between “GET” and “POST” depends on the nature of the data being submitted and the desired behavior of the form. Use “GET” for simple queries or retrieving data and “POST” for submitting data that may contain sensitive or large information.

Article Tags :