Fandom

HTML & CSS Wiki

Form

649pages on
this wiki
Add New Page
Comments0 Share


The HTML <form></form> element is identical to a <div></div> (i.e., block-level but otherwise inconsequential) except that it cannot contain other forms and, when it is "submitted," the browser will send a new request to the server for the page indicated in the action attribute. The HTTP method for the request is specified in the method attribute, typically either get or post. (While the HTTP standard defines them in uppercase[1] and HTML syntax allows either case, XHTML requires lowercase[2]; the XHTML syntax is recommended.)

A GET request will send any values of the form's child elements in the URL, while a POST sends them separately. GET (the default, used when a URL is entered into a browser's location field) is intended for requests which will only cause the server to respond with some information specified by those values; POST is prescribed for changing that information. Forms are typically associated with databases on the server side, although various other purposes could be conceived including flat-files (essentially primitive databases), filesystem modifications, and requests to other servers.

Attributes

Optional attributes

Values listed in ( ) (parentheses or round brackets), separated by | (pipes or vertical bars), are for enumerated attributes; the bold value is the default.

Attribute Value Description
accept-charset charset The character set in which to encode the submission.
action URL The page, typically a server-side script, which will receive the submission.
autocomplete ( on | off ) Whether the browser will remember values entered by the user.
enctype ( application/x-www-form-urlencoded
| multipart/form-data
| text/plain )
method ( get | post | put | delete ) The HTTP request method.
name text A unique, non-empty name which will be associated with the form in the forms collection.
novalidate boolean Prevents the browser from validating the form during submission to filter out mistaken entries.
target browsing context name Indicates the new or existing window (or tab, frame, etc.) in which the action will be requested.


Global attributes

See Global HTML Attributes.

See Also

External links

References

  1. http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
  2. http://www.w3.org/TR/xhtml1/#h-4.11

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.