HTML <form> tag
Definition and Usage
The form element creates 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.
Differences Between HTML and XHTML
NONE
Example
| Source |
Output |
<form
action="form_action.asp"
method="get">
First name:
<input type="text" name="fname" value="Mickey"
/>
<br />
Last name:
<input type="text" name="lname" value="Mouse"
/>
<br />
<input type="submit" value="Submit" />
</form>
<p>
If you click the "Submit" button, you will send your input to a new page
called form_action.asp.
</p> |
If you click the "Submit" button, you will send your input to a new page called
form_action.asp.
|
Required Attributes
DTD indicates in which DTD the attribute is
allowed. S=Strict, T=Transitional, and F=Frameset.
| Attribute |
Value |
Description |
DTD |
| action |
URL |
A URL that defines where to send the data when the submit button
is pushed |
STF |
Optional Attributes
| Attribute |
Value |
Description |
DTD |
| accept |
list of contenttypes |
A comma separated list of content types that the server
that processes this form will handle correctly |
STF |
| accept-charset |
charset_list |
A comma separated list of possible character sets for the
form data. The default value is
"unknown" |
STF |
| enctype |
mimetype |
The mime type used to encode the content of the form |
STF |
| method |
get
post |
The HTTP method for sending data to the action URL. Default
is get. method="get": This method sends the form contents
in the URL: URL?name=value&name=value. Note: If the form values contains non-ASCII characters or
exceeds 100
characters you MUST use method="post".
method="post": This method sends the form contents in the body of the request.
Note: Most browsers are
unable to bookmark post requests.
|
STF |
| name |
form_name |
Defines a unique name for the form |
TF |
| target |
_blank
_self
_parent
_top |
Where to open the target 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
|
TF |
Standard Attributes
| id, class, title, style, dir, lang, xml:lang |
For a full description, go to Standard
Attributes.
Event Attributes
| onsubmit, onreset, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup |
For a full description, go to Event
Attributes.
Try-It-Yourself Demos
Form with
input fields and a submit button
How to add a form to a page. The form contains two input fields and a submit
button.
Form with
checkboxes
This form contains two checkboxes, and a submit button.
Form with
radiobuttons
This form contains two radio buttons, and a submit button.
Send e-mail
from a form
How to send e-mail from a form.
Learn XML with <oXygen/> XML Editor - Free Trial!
 |
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|