From http://www.w3schools.com (Copyright Refsnes Data)
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.
HTML 5 has some new attributes, and some HTML 4.01 attributes are no longer supported.
HTML 5 has a new attribute: replace. Which defines what to do after a for has been submitted.
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. |
Attribute | Value | Description | 4 | 5 |
---|---|---|---|---|
action | URL | A URL that defines where to send the data when the submit button is pushed | 4 | 5 |
data | URL | For inserting data automatically | 5 | |
replace | value | Defines what to to when a form has been submitted | 5 | |
accept | list of contenttypes | A comma separated list of content types that the server that processes this form will handle correctly | 4 | 5 |
accept-charset | charset_list | A comma separated list of possible character sets for the form data. The default value is "unknown" | 4 | 5 |
enctype | mimetype | The mime type used to encode the content of the form | 4 | 5 |
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. |
4 | 5 |
name | form_name | Defines a unique name for the form. Not supported, use id instead | 4 | |
target | _blank _self _parent _top |
Where to open the target URL.
|
4 | 5 |
class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title |
For a full description, go to Standard Attributes in HTML 5.
onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload |
For a full description, go to Event Attributes in HTML 5.
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.
From http://www.w3schools.com (Copyright Refsnes Data)