CSS Portal

HTML formmethod Attribute

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The formmethod attribute in HTML is used to specify the method by which the form data should be submitted to the server. It can be applied to <button> or <input> elements within a form, overriding the default or specified method attribute of the form element itself. This attribute provides flexibility in defining submission behaviors for specific buttons or input elements within the same form.

The formmethod attribute provides an easy way to configure different submission methods for multiple submit buttons within the same form, allowing for more complex interactions and behaviors in web forms.

Syntax

<tagname type="submit" formmethod="get | post">

Values

  • getThis value specifies that the form data should be appended to the form's action URL, with the fields in the form becoming parameters in the query string of the URL. The GET method is typically used for form submissions where the user is requesting data from the server, without intending to create or update resources.
  • postThis value indicates that the form data should be included in the body of the HTTP request. The POST method is commonly used for form submissions that create or update data on the server because it does not expose the form data in the URL, offering a more secure way of transmitting sensitive information.

Applies To

Example

<form action="formscript.php" method="get">
Name: <input type="text" name="username"><br><br>
Email: <input type="email" name="email"><br><br>
<input type="submit" value="Submit (GET)"><br><br>
<input type="submit" value="Submit (POST)" formmethod="post">
</form>

Browser Support

The following information will show you the current browser support for the HTML formmethod attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 29th March 2024

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!