HTML <form>Tag
Examples
An HTML form with two input fields and a submit button:
Try it Yourself »
(More examples at the bottom of the page)
Browser Support
![]()
All major browsers support the <form> tag.
Definition and Usage
The <form> tag is used to create an HTML form for user input.
The <form> element contains one or more of the following form elements:
Differences between HTML 4.01 and HTML5
HTML5 added two new attributes: autocomplete and novalidate, and no longer supports some attributes from HTML 4.01.
Differences between HTML and XHTML
In XHTML, the name attribute is deprecated. Use the global id attribute instead.
Attributes
New: New attributes in HTML5.
| Attribute | Value | Description |
|---|---|---|
| accept | MIME_type | Not supported in HTML5.Specifies the type of file that the server receives. (The file is submitted via file upload) |
| accept-charset | character_set | Specifies the character set of the form data that the server can process. |
| action | URL | Specifies where to send the form data when the form is submitted. |
| autocompleteNew | on off |
Specifies whether the form's autocomplete feature is enabled. |
| enctype | application/x-www-form-urlencoded multipart/form-data text/plain |
Specifies how to encode form data before sending it to the server. (Applies to method="post") |
| method | get post |
Specifies the HTTP method used to send form data. |
| name | text | Specifies the name of the form. |
| novalidateNew | novalidate | If this attribute is used, the form is not validated when submitted. |
| target | _blank _self _parent _top |
Specifies where to open the action URL. |
Global Attributes
The <form> tag supportsHTML Global Attributes。
Event Attributes
The <form> tag supportsHTML Event Attributes。
Try it Yourself - Examples
A form with checkboxes
This form contains two checkboxes and a submit button.
A form with radio buttons
This form contains two radio buttons and a submit button.
Related Articles
HTML Tutorial:HTML Forms and Input
HTML DOM Reference:Form Object
Other Extensions