HTML method Attribute

❮ HTML Attributes


<form action="action.php" method="get">
	<label for="fname">First name:</label>
	<input type="text" id="fname" name="fname"><br>
	<label for="lname">Last name:</label>
	<input type="text" id="lname" name="lname"><br>
	<input type="submit" value="Submit">


The method attribute specifies how form information should be transferred to the server using a particular HTTP method.

A get value in the attribute specifies that form data should be appended to the URL specified by the action attribute, thus creating a query string. But it imposes a size limitation variation between browser.

A value of post for this attribute transfers the data of the form in the message body using the HTTP POST method which imposes no data size limitation.

The POST method must be used when file attachments are used in a form.

Standard Syntax

<element method="get|post">

Browser Support


Applies to:

The method attribute can be used on the following element:

Element Attribute
<form> method

Attribute Values

Value Description
get The GET method form data appended to the action URL with a ? separator. Use this method when the form has no side-effects.
post The POST method form data sent as the request body.
dialog (new) When the form is inside a <dialog>, closes the dialog on submission.
❮ HTML Attributes