Tag Description
The form tag is used to create an HTML form for user input. Forms are used to pass user-data to a server.
This tag has the form:
<form action="URL" enctype="{ application/x-www-form-urlencoded | multipart/form-data | text/plain }" method="{ get | post }">
</form>
HTML5 and HTML4.01 Differences
HTML5 has defined new attributes, and some HTML4.01 attributes are not supported in HTML5.
HTML5 | = New for HTML5 |
Attributes
Attribute | Value | Description |
---|---|---|
accept | MIME_type | Specifies the types of files that can be submitted through a file upload
HTML4:
![]() HTML5:
![]() |
accept-charset | charset | Specifies the character sets the server can handle for form-data |
action | URL | (required) Specifies where to send the form-data when a form is submitted |
autocompleteHTML5 | on
off |
Specifies whether a form should have autocomplete on or off.
If "on" browsers can store the form's input values, to auto-fill the form if the user returns to the page. If "off" browsers should not store this information |
enctype | application/x-www-form-urlencoded
multipart/form-data text/plain |
Specifies how form-data should be encoded before sending it to a server.
The default is application/x-www-form-urlencoded |
method | get
post |
Specifies the HTTP method to use when sending form-data |
name | text | Specifies the name for a form |
novalidateHTML5 | novalidate | If present the form should not be validated when submitted |
target | _blank
_self _parent _top |
Specifies where to open the target URL.
|
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<form action="form_action.asp" method="get">
First name:
<input type="text" name="fname" />
Last name:
<input type="text" name="lname" />
<input type="submit" value="Submit" />
</form>
This produces the following result:
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |