docs.rodeo

MDN Web Docs mirror

: The Form element

{{HTMLSidebar}} 

The <form> HTML element represents a document section containing interactive controls for submitting information.

{{EmbedInteractiveExample("pages/tabbed/form.html", "tabbed-standard")}} 

It is possible to use the {{cssxref(':valid')}}  and {{cssxref(':invalid')}}  CSS pseudo-classes to style a <form> element based on whether the {{domxref("HTMLFormElement.elements", "elements")}}  inside the form are valid.

Attributes

This element includes the global attributes.

Attributes for form submission

The following attributes control behavior during form submission.

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

{{EmbedLiveSample('Examples')}} 

Technical summary

Content categories Flow content, palpable content
Permitted content Flow content, but not containing <form> elements
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts flow content
Implicit ARIA role form
Permitted ARIA roles search, none or presentation
DOM interface `{{domxref("HTMLFormElement")}}` 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN