HTML - <form>

The HTML <form> element represents a document section that contains interactive controls to submit information to a web server.

Example

 

HTML
<!-- Simple form which will send a GET request -->
<form action="">
  <label for="GET-name">Name:</label>
  <input id="GET-name" type="text">
  <input type="submit" value="Save">
</form>

<!-- Simple form which will send a POST request -->
<form action="" method="post">
  <label for="POST-name">Name:</label>
  <input id="POST-name" type="text">
  <input type="submit" value="Save">
</form>

<!-- Form with fieldset, legend, and label -->
<form action="" method="post">
  <fieldset>
    <legend>Title</legend>
    <input type="radio" id="radio"> <label for="radio">Click me</label>
  </fieldset>
</form>

Description  

The HTML <form> element represents a document section that contains interactive controls to submit information to a web server.

It is possible to use the :valid and :invalid CSS pseudo-classes to style a <form> element.

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 parent elements Any element that accepts flow content
DOM interface HTMLFormElement

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0[1] 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
novalidate attribute 1.0 4.0 (2.0) 10 ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)
novalidate attribute ? 4.0 (2.0) (Yes) ? ?

[1] The Google Chrome UI for auto-complete request varies, depending on whether autocomplete is set to off on input elements as well as their form. Specifically, when a form has autocomplete set to off and its input element's autocomplete field is not set, then if the user asks for autofill suggestions for the input element, Chrome might display a message saying "autocomplete has been disabled for this form." On the other hand, if both the form and the input element have autocomplete set to off, the browser will not display that message. For this reason, you should set autocomplete to off for each input that has custom auto-completion.

See Also  

Specifications  

Specification Status Comment
WHATWG HTML Living Standard
The definition of '<form>' in that specification.
Living Standard  
HTML5
The definition of '<form>' in that specification.
Recommendation  
HTML 4.01 Specification
The definition of '<form>' in that specification.
Recommendation Initial definition

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/html/element/form

Element Forms HTML HTML forms Intermediate Reference Web