From http://www.w3schools.com (Copyright Refsnes Data)
ExampleA simple HTML form with two input fields and one submit button:
Try it yourself! (more examples at the bottom of this page) |
The <form> tag is used to create an HTML form for user input.
A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A forms can also contain select menus, textarea, fieldset, legend, and label elements.
Forms are used to pass data to a server.
The <form> tag is supported in all major browsers.
NONE
Note: Form is a block-level element, and creates a line break before and after itself.
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 |
Attribute | Value | Description | DTD |
---|---|---|---|
accept | list of content types | 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.
|
TF |
id, class, title, style, dir, lang, xml:lang |
For a full description, go to Standard Attributes.
onsubmit, onreset, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup |
For a full description, go to Event Attributes.
Form with
checkboxes
A form with two checkboxes, and a submit button.
Form with
radiobuttons
A form with two radio buttons, and a submit button.
Send e-mail
from a form
How to send e-mail from a form.
From http://www.w3schools.com (Copyright Refsnes Data)