form

FilterElements

<form> ... </form>

Indicates an interactive form that contains controls for collecting user input and other page content. There may be more than one form in a document, but forms may not be nested inside one another, and it is important that they do not overlap.

Start/End Tags

Required/Required

Specifications

  • HTML 4.01
  • HTML5

accept=

Values: content-type-list
Not in HTML5. Specifies a comma-separated list of file types (MIME types) that the server will accept and is able to process. One day browsers may be able to filter out unacceptable files when prompting a user to upload files to the server, but this attribute is not widely supported yet.

accept-charset=

Values: charset list
Specifies the list of character encodings for input data that must be accepted by the server to process the current form. The value is a space- and/or comma-delimited list of ISO character set names. The default value is unknown. This attribute is not widely supported.

action=

Values: URL
Required. Specifies the URL of the application that will process the form. The default is the current URL.

autocomplete=

Values: on | off
HTML5 only. Allows the user agent (browser) to fill in a field automatically (on) or requires the user to enter the information every time (off). Omitting this attribute causes the control to inherit the autocomplete setting for the associated form element.

enctype=

Values: content type
Specifies how the values for the form controls are encoded when they are submitted to the server when the method is post. The default is the Internet Media Type (application/x-www-form-urlencoded ). The value multipart/form-data should be used in combination with the file input element.

method=

Values: get | post
Specifies which HTTP method will be used to submit the form data. With get (the default), the information is appended to and sent along with the URL itself.

name=

Values: text
Deprecated in XHTML 1.0; use id instead. Assigns a name to the form.

novalidate

Values: novalidate="novalidate" in XHTML.
HTML5 only. Indicates that the form is not to be validated during submission.

target=

Values: name
Specifies a target for the results of the form submission to be loaded so that results of a form can be displayed in another window or frame. The special target values _bottom, _top, _parent, and _self may be used.

HTML 4.01 <form> Events

onblur
Occurs when the form loses focus
onreset
Occurs when the form is reset
onsubmit
Occurs when the form is submitted
<form action="/cgi-bin/guestbook.pl" method="get">
<p>First Name: <input type="text" name="first"></p>
<p>Nickname: <input type="text" name="nickname"></p>
<p><input type="submit" /> <input type="reset"></p>
</form>

Rendered Example

Nickname: