You are here: Reference > HTML > tags > form

form element

Browser support:
Creates a container element for controls.
The form element allows users to submit data to a server. The target URL can be specified with the action attribute. The method attribute defines the way of sending.
The contents of the message submitted to the server depend on the named form controls in the form tag. Named control means an element with a non-empty name attribute.
Only the contents or the state of the named form controls will be sent.
The following elements are form controls: When a form is submitted, the message contains the name/value pairs belonging to the named controls in the form. The name parameter is the value of the name attribute of the control. The contents of the value parameter depend on the type of the control.
Push buttons (button, input:button, input:reset, input:submit) don't play an important part in the message. If a push button is named and it is in pushed state when the form is submitted, then the name and the value (the value of the value attribute) of the button will be sent with the form. If a push button is not in pushed state, no information is sent with the form that belongs to the button. Since only one push button can be in pushed state at any time, they don't play an important part in the message.
The reset button can be used to reset all controls to their initial values within the form. The user can send the form to the server by clicking on the submit button.
The other controls are useful for the message submitted to the server.
If you want to see the HTML tags by categories, please visit this page.
This element requires a closing tag.
JavaScript page for this element: form.

Possible members:

Attributes
Events
Styles
Pseudos
accept
Sets a comma-separated list of accepted content types.
accept-charset
Sets a list of character encodings for a form.
accessKey
Sets an access key to an element.
action
Sets a form processing agent. With this attribute you can set an URL to call when the form is sent.
autoComplete
Sets whether the text field should give the user some suggestion during typing.
class
Sets the style class or classes that belong to the element.
contentEditable
3
Sets whether the contents of the object are editable.
dir
Sets the text direction as related to the lang attribute.
DISABLED
Sets the state of an object for user interaction.
draggable
3.55
Sets whether an element is draggable.
encType
Sets how form data should be encoded for submitting to the server.
HIDEFOCUS
Specifies whether a dotted rectangle (focus rectangle) is drawn around an object while it has focus.
id
Sets a unique identifier for the object.
lang
Specifies the language of the element.
language
Sets the scripting language for the current element. Use it only for the script element.
method
Specifies how the data of a form should be submitted to the server. When the user clicks on the submit button of a form, the data of the named elements in the form will be sent. The data contains the name and the value of the named element.
name
Sets the name of an element.
spellcheck
Sets whether the automatic spellchecker is enabled.
style
Sets an inline style associated with an element.
tabIndex
Specifies the tabbing order for keyboard navigation using the TAB key.
target
Specifies the target window or frame where the document is to be opened.
title
Specifies a tooltip for an element.
unSelectable
Sets whether the selection process can start in an element's content.
xml:lang
Sets the language code of the XML document.

Example HTML code 1:

This example illustrates the use of the form element:
<form action="#URL#" method="post">
    User Name: <input type="text" name="userName" />
    <br />
    Password: <input type="password" name="password" />
    <br />
    <input type="reset" value="Reset" />
    <input type="submit" value="Sign in" />
</form>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content