The HTML element represents a document section containing interactive controls for submitting information. It is possible to use the
:valid and :invalid CSS pseudo-classes to style a element based on whether or not the elements
inside the form are valid. 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.] Try it
Attributes
A nonstandard attribute used by iOS Safari that controls how textual form elements should be automatically capitalized. autocapitalize attributes on a form elements override it on . Possible values:
- none: No automatic capitalization.
- sentences [default]: Capitalize the first letter of each sentence.
- words: Capitalize the first letter of each word.
- characters: Capitalize all characters — that is, uppercase.
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:
- off: The browser may not automatically complete entries. [Browsers tend to ignore this for suspected login forms; see The autocomplete attribute and login fields.]
- on: The browser may automatically complete entries.
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.
relCreates a hyperlink or annotation depending on the value, see the rel attribute for details.
Attributes for form submission
The following attributes control behavior during form submission.
actionThe 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:
- application/x-www-form-urlencoded: The default value.
- multipart/form-data: Use this if the form contains elements with type=file.
- text/plain: Useful for debugging purposes.
This value can be overridden by formenctype attributes on , , or elements.
methodThe HTTP method to submit the form with. The only allowed methods/values are [case insensitive]:
- post: The POST method; form data sent as the request body.
- get: The GET method; form data appended to the action URL with a ? separator. Use this method when the form has no side-effects.
- dialog: When the form is inside a , closes the dialog and throws a submit event on submission without submitting data or clearing the form.
This value is overridden by formmethod attributes on , , or elements.
novalidateThis 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.
targetIndicates 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:
- _self [default]: Load into the same browsing context as the current one.
- _blank: Load into a new unnamed browsing context.
- _parent: Load into the parent browsing context of the current one. If no parent, behaves the same as _self.
- _top: Load into the top-level browsing context [i.e., the browsing context that is an ancestor of the current one and has no parent]. If no parent, behaves the same as _self.
This value can be overridden by a formtarget attribute on a , , or element.
Note: Setting target="_blank" on elements implicitly provides the same rel behavior as setting rel="noopener" which does not set window.opener.
Examples
HTML
Name: Save Name: Save Title Select me
Specifications
HTML Standard # the-form-element |
Browser compatibility
BCD tables only load in the browser
See also
- HTML forms guide
- Other elements that are used when creating forms: , , , , , , , , , , , , .
- Getting a list of the elements in the form: HTMLFormElement.elements
- ARIA: Form role
- ARIA: Search role