: The Form element

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015 .

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

Try it

It is possible to use the :valid and :invalid CSS pseudo-classes to style a element based on whether the elements inside the form are valid.

Attributes

This element includes the global attributes.

Comma-separated content types the server accepts.

Note: This attribute has been deprecated and should not be used. Instead, use the accept attribute on elements.

Space-separated character encodings the server accepts. The browser uses them in the order in which they are listed. The default value means the same encoding as the page. (In previous versions of HTML, character encodings could also be delimited by commas.)

Controls whether inputted text is automatically capitalized and, if so, in what manner. See the autocapitalize global attribute page for more information.

Indicates whether input elements can by default have their values automatically completed by the browser. autocomplete attributes on form elements override it on . Possible values:

The name of the form. The value must not be the empty string, and must be unique among the form elements in the forms collection that it is in, if any.

Controls the annotations and what kinds of links the form creates. Annotations include external , nofollow , opener , noopener , and noreferrer . Link types include help , prev , next , search , and license . The rel value is a space-separated list of these enumerated values.

Attributes for form submission

The following attributes control behavior during form submission.

The URL that processes the form submission. This value can be overridden by a formaction attribute on a , , or element. This attribute is ignored when method="dialog" is set.

If the value of the method attribute is post , enctype is the MIME type of the form submission. Possible values:

This value can be overridden by formenctype attributes on , , or elements.

The HTTP method to submit the form with. The only allowed methods/values are (case insensitive):

This value is overridden by formmethod attributes on , , or elements.

This Boolean attribute indicates that the form shouldn't be validated when submitted. If this attribute is not set (and therefore the form is validated), it can be overridden by a formnovalidate attribute on a , , or element belonging to the form.

Indicates where to display the response after submitting the form. It is a name/keyword for a browsing context (for example, tab, window, or iframe). The following keywords have special meanings:

This value can be overridden by a formtarget attribute on a , , or element.

Examples

form method="get"> label> Name: input name="submitted-name" autocomplete="name" /> label> button>Savebutton> form> form method="post"> label> Name: input name="submitted-name" autocomplete="name" /> label> button>Savebutton> form> form method="post"> fieldset> legend>Do you agree to the terms?legend> label>input type="radio" name="radio" value="yes" /> Yeslabel> label>input type="radio" name="radio" value="no" /> Nolabel> fieldset> form> 

Result

Technical summary

Content categories Flow content, palpable content
Permitted content Flow content, but not containing 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 HTMLFormElement

Specifications

Specification
HTML Standard
# the-form-element

Browser compatibility

BCD tables only load in the browser

See also