The <form> element

A web page's <form> element is used to create a form on the page, collect user data and send that data to an application for processing. For example, when you shop online, you fill out a form indicating the product and the number of items and then submit it for processing. The DOM HTMLFormElement Interface provides the properties and methods. Forms must have a unique name Forms also must contain a method which says how the data will be sent to the application. Examples show how to use the post and get methods to send user data to an application.

Examples

<!-- Form which will send a GET request to the current URL -->
<form method="get">
  <label>
    Name:
    <input name="submitted-name" autocomplete="name" />
  </label>
  <button>Save</button>
</form>

<!-- Form which will send a POST request to the current URL -->
<form method="post">
  <label>
    Name:
    <input name="submitted-name" autocomplete="name" />
  </label>
  <button>Save</button>
</form>

<!-- Form with fieldset, legend, and label -->
<form method="post">
  <fieldset>
    <legend>Do you agree to the terms?</legend>
    <label><input type="radio" name="radio" value="yes" /> Yes</label>
    <label><input type="radio" name="radio" value="no" /> No</label>
  </fieldset>
</form>


Result