HTML 4 form Tag
Also see HTML5 <form>
Tag.
This page contains information about the HTML 4 version of this element. For a more up to date version, see HTML5 <form>
Tag.
The HTML form
tag is used for declaring a form.
The <form>
tag is used in conjunction with form-associated elements. To create a form, you can nest form-associated elements inside the opening/closing <form>
tags.
Form-Associated Elements
Here are the elements that you can use with your forms.
These elements allow the user to provide information to the website - information which can be submitted to the server for processing.
HTML 5 gives forms the ability to have improved functionality. For example, a form element can contain the form
attribute to bind itself to a form. HTML 5 also introduces the <datalist>
element. For more information, see the HTML 5 <form>
element.
Example
Attributes
Attributes specific to this tag: | |
---|---|
Attribute | Description |
action | Specifies a URI/URL of the page that will process the form. |
method | Specifies the HTTP method to use when the form is submitted. Possible values:
|
enctype | Specifies the content type used to encode the form data set when it's submitted to the server. Possible values:
|
accept-charset | Specifies a list of character encodings that the server accepts. The default value is "UNKNOWN". |
accept | Specifies a comma-separated list of content types that the server accepts. |
name | Assigns a name to the form. This is used when referencing the form with stylesheets or scripts. If there are multiple forms, the name of each form must be unique. |
Other Attributes: | |
Attribute | Description |
class | Document wide identifier. |
id | Document wide identifier |
dir | Specifies the direction of the text |
lang | Language code |
target | Specifies the target frame to load the destination page as indicated with the action attribute. |
onSubmit | Intrinsic event (see event handlers) |
onReset | Intrinsic event (see event handlers) |
onclick | Intrinsic event (see event handlers) |
ondbclick | Intrinsic event (see event handlers) |
onmousedown | Intrinsic event (see event handlers) |
onmouseup | Intrinsic event (see event handlers) |
onmouseover | Intrinsic event (see event handlers) |
onmousemove | Intrinsic event (see event handlers) |
onmouseout | Intrinsic event (see event handlers) |
onkeypress | Intrinsic event (see event handlers) |
onkeydown | Intrinsic event (see event handlers) |
onkeyup | Intrinsic event (see event handlers) |
HTML5 Tags
The information on this page is based on HTML version 4.01. Most modern browsers now support HTML5, which is the next version of HTML after HTML 4.01.
See HTML5 <form>
Tag for the HTML5 version of the above element.
Also see this list of HTML 5 tags for the latest version of HTML.