HTML Home
HTML Tags Reference
Selected Reading
© 2008 TutorialsPoint.COM
|
HTML <form> tag
Function:
The HTML <form> tag is used for creating a form for user input. A form can contain textfields, checkboxes, radio-buttons and more. Forms are used to pass user-data to a specified URL.
Difference between HTML and XHTML:
NONE
Example:
<form action="/cgi-bin/hello_get.cgi" 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>
|
This will produce following result:
Online Practice:
To Become more comfortable - Do Online Practice
Attributes:
| Attribute | Value | Description |
| action | URL | Specifies a URI/URL of the back-end script that will process the form. |
| accept | content types | Specifies a comma-separated list of content types that the server accepts. |
| accept-charset | charset list | Specifies a list of character encodings that the server accepts. The default value is "unknown". |
| enctype | mimetypes | The mime type used to encode the content of the form. |
| method | get post | 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)
|
| name | from name | Defines a unique name for the form |
| target | _blank _self _parent _top | Target to open the given URL.
- _blank - the target URL will open in a new window
- _self - the target URL will open in the same frame as it was clicked
- _parent - the target URL will open in the parent frameset
- _top - the target URL will open in the full body of the window
|
Standard Attributes:
| Attribute | Description |
| class | Document wide identifier |
| dir | Specifies the direction of the text |
| id | Document wide identifier |
| title | Specifies a title to associate with the element. |
| style | Helps to include inline casecadubf style sheet. |
| lang | Sets the language code. |
Event Attributes:
| Attribute | Description |
| onclick | Script runs when a mouse click |
| ondblclick | Script runs when a mouse double-click |
| onmousedown | Script runs when mouse button is pressed |
| onmouseup | Script runs when mouse button is released |
| onmouseover | Script runs when mouse pointer moves over an element |
| onmousemove | Script runs when mouse pointer moves |
| onmouseout | Script runs when mouse pointer moves out of an element |
| onkeypress | Script runs when key is pressed and released |
| onkeydown | Script runs when key is pressed |
| onkeyup | Script runs when key is released |
| onsubmit | Script runs when from is submitted |
| onreset | Script runs when from is reset |
|
|
|