form ElementThe form element is a block-level element declared by the XHTML 1.1 Forms Module
Elements in the Forms Module are:form | label | textarea | select | optgroup | option | button | fieldset | legend | input type="button" | input type="checkbox" | input type="file" | input type="hidden" | input type="image" | input type="password" | input type="radio" | input type="reset" | input type="submit" | input type="text"
The form element is used to enclose
a set of form controls (see the Forms Module
for a list of form control elements).
These controls allow interaction with the
user and include, for example, text boxes
to be filled in, buttons to be checked or pressed, options
to be selected, and so on. The form
element itself provides a container for these controls and
specifies:
action
attribute.method
attribute.enctype
attribute.accept-charset attribute.accept attribute.If you use any file upload controls (see
input type="file")
within a form you must specify an
enctype
of "multipart/form-data" and a
method
of "post".
Form submit buttons can be created using input type="submit",
input type="image" or button
elements.
A form element may have only block level
elements (such as div or
p) as children. The
form-specific fieldset
element may also be used - see the above Content Model
for details. The form controls themselves
must be placed inside these block children.
Here is a simple example form which contains only a single text input field and a submit button:
<form action="processform.cgi" method="post" accept-charset="utf-8">
<div>
<label for="email">Email Address:</label>
<input type="text" id="email" name="email" size="30" value="Please enter your email address" />
<input type="submit" value="Submit" />
</div>
</form>
The input type="text"
form control element creates a text box in which the user can enter arbitrary text to be submitted.
This example is rendered below (although the action URI has been altered because processform.cgi does not
exist here - pressing the button will just return you to this details section and nothing else will happen - after
all, it is just an example!)
The action attribute is #REQUIRED on the form element.
form element are listed below:accept [ type ContentTypes ]form's processing scriptaccept-charset [ type Charsets ]action [ type URI - #REQUIRED ]action is given a value other than a URIenctype [ type ContentType - default="application/x-www-form-urlencoded" ]method="post", this specifies the content type of the submitted data. Behaviour for enctype values other than "application/x-www-form-urlencoded" and "multipart/form-data" is unspecified.method [ type Enumeration (get | post) - default="get" ]input type="file" within the form, method should be "post" with an enctype of "multipart/form-data".onreset [ type Script ]onsubmit [ type Script ]target [ type FrameTarget ]form element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
form element is:
( BlkNoForm.mix | fieldset )+
NOTE: This element cannot be empty
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
formaddress, blockquote, div, h1 - h6, p, predl, ol, ultablefieldsethrnoscript, scriptdel, insNote:
A form element must never contain another form element, at any nesting depth.
See Descendant Exclusions.
formbodyblockquote, divdd, litd, thfieldsetmapnoscriptdel, insobject