HTML form Tag
The information on this page is based on HTML version 4.01 (which is the current version of HTML). The next version, HTML 5, is currently being written. Here's a list of HTML 5 tags.
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 |
<form action="/html/tags/html_form_tag_action.cfm" method="get">
First name:
<input type="text" name="first_name" value="" maxlength="100" />
<br />
Last name:
<input type="text" name="last_name" value="" maxlength="100" />
<input type="submit" value="Submit" />
</form>
The above code produces the following form:
|
| 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:- get (the form data is appended to the URL when submitted)
- post (the form data is not appended to the URL)
|
| enctype | Specifies the content type used to encode the form data set when it's submitted to the server. Possible values:- application/x-www-form-urlencoded (default)
- multipart/form-data (use this when uploading files)
|
| 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) |
|
Also see the HTML 5 version of HTML tags
Enjoy this page?
-
- Link to this page (copy/paste into your own website or blog):
- Link to Quackit using one of these banner ads.
Thanks for supporting Quackit!