HTML <button> Tag with the 'formmethod' Attribute

<!-- ...form contents... -->

<button type="submit" formaction="" formmethod="post">


In the above example we add the formmethod attribute to a button control.

About the formmethod Attribute

The formmethod attribute allows you to specify the HTTP method to use when the control is submitted.

Possible values:

  • get (the form data is appended to the URL when submitted)
  • post (the form data is not appended to the URL)
  • dialog (specifies that submitting the form is intended to close the dialog box in which the form finds itself, if any, and otherwise not submit.)

The W3C says:

If the element is a submit button and has a formmethod attribute, then the element's method is that attribute's state; otherwise, it is the form owner's method attribute's state.

About the <button> Element

The <button> element creates a button control in an HTML document.

Any contents of the <button> element appears on the button.

The <button> element can be associated with a form or stand alone by itself (in such case it could have JavaScript attached via the onclick attribute) to make the button actually do something.