The XHTML WYSIWYG Editor For Desktop & Web Applications

form

Definition

The form element is used to create data entry forms. Data collected in the form is sent to the server for processing by server-side scripts such as PHP, ASP, etc.

Example

  1. <form method="post" action="register.php">
  2. <fieldset>
  3. <legend>Personal information</legend>
  4. <label for="firstname">First name</label><br />
  5. <input type="text" name="firstname" id="firstname" /><br />
  6. <label for="lastname">Last name</label><br />
  7. <input type="text" name="lastname" id="lastname" />
  8. </fieldset>
  9. <fieldset>
  10. <legend>Medical history</legend>
  11. <input name="history" type="checkbox" value="1" id="smallpox" />
  12. <label for="smallpox">Smallpox</label><br />
  13. <input name="history" type="checkbox" value="2" id="mumps" />
  14. <label for="mumps">Mumps</label><br />
  15. <input name="history" type="checkbox" value="3" id="dizziness" />
  16. <label for="dizziness">Dizziness</label>
  17. </fieldset>
  18. </form>

Attributes

Basic

action
(URI) Specifies the location of the server-side script used to process data collected in the form.
method
Specifies the type of HTTP method used to send data to the server. The default is get when the form data is sent to the server encoded into the URL specified in the action attribute. Most forms use post when form data is sent to the server in the body of the HTTP message.

Advanced

accept
(ContentTypes) This attribute specifies a comma-separated list of content types that a server processing the form will handle correctly.
accept-charsets
(Charsets) This attribute specifies the list of character encodings for input data that are accepted by the server processing the form.
enctype
(ContentType) This attribute specifies the content type used to send form data to the server when the value of method is post. The default value for this attribute is application/x-www-form-urlencoded. If a form contains a file upload control (input element with type value of file), then this attribute value should be multipart/form-data.
onreset
(Script) A client-side script event that occurs when a form is reset (all form controls are set to their initial values).
onsubmit
(Script) A client-side script event that occurs when a form is submitted (form data is sent to server-side scripts for processing).

Common core attributes

class
(NameTokens) This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or set of class names. Multiple class names must be separated by white space characters. Class names are typically used to apply CSS formatting rules to an element.
id
(ID) This attribute assigns an ID to an element. This ID must be unique in a document. This ID can be used by client-side scripts (such as JavaScript) to select elements, apply CSS formatting rules, or to build relationships between elements.
title
(Text) This attribute offers advisory information. Some Web browsers will display this information as tooltips. Assistive technologies may make this information available to users as additional information about the element.

Common internationalization attributes

xml:lang
(NameToken) This attribute specifies the base language of an element's attribute values and text content.
dir

This attribute specifies the base direction of text. Possible values:

  • ltr: Left-to-right
  • rtl: Right-to-left

Common event attributes

onclick
(Script) A client-side script event that occurs when a pointing device button is clicked over an element.
ondblclick
(Script) A client-side script event that occurs when a pointing device button is double-clicked over an element.
onmousedown
(Script) A client-side script event that occurs when a pointing device button is pressed down over an element.
onmouseup
(Script) A client-side script event that occurs when a pointing device button is released over an element.
onmouseover
(Script) A client-side script event that occurs when a pointing device is moved onto an element.
onmousemove
(Script) A client-side script event that occurs when a pointing device is moved within an element.
onmouseout
(Script) A client-side script event that occurs when a pointing device is moved away from an element.
onkeypress
(Script) A client-side script event that occurs when a key is pressed down over an element then released.
onkeydown
(Script) A client-side script event that occurs when a key is pressed down over an element.
onkeyup
(Script) A client-side script event that occurs when a key is released over an element.

Common style attribute

style
(Text) This attribute specifies formatting style information for the current element. The content of this attribute is called inline CSS. The style attribute is deprecated (considered outdated), because it fuses together content and formatting.

Contains