Tags
<!-->
<!DOCTYPE>
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<b>
<base>
<basefont>
<bdo>
<big>
<blockquote>
<body>
<br>
<button>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<dd>
<del>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<fieldset>
<font>
<form>
<frame>
<frameset>
<head>
<h1> - <h6>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<label>
<legend>
<li>
<link>
<map>
<menu>
<meta>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<p>
<param>
<pre>
<q>
<s>
<samp>
<script>
<select>
<small>
<span>
<strike>
<strong>
<style>
<sub>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<title>
<tr>
<tt>
<u>
<ul>
<var>

Standard
Attributes
Events

The <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>
First name:
Last name:

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.