A form is a section of a document that contains blank areas that can be filled by a user and submitted to be processed. In (X)HTML the form element is used to create a form. It contains various form controls. It is a block element and can have only block elements and the script element as children. form elements cannot be nested within each other.
These are the allowed child elements of form:
ph1toh6ulandolpredldivnoscriptblockquotehrtablefieldsetaddressscript
Attributes
- Core Attributes
- The core attributes can be applied to this element.
acceptThe value of this attribute is a comma-separated list of MIME types which the server can process. Browsers should not allow a user to upload files of a type that is not listed. However, none of the major browsers support this feature.
Example:
<form action="" accept="image/gif, image/jpeg">accept-charsetThis attribute specifies the character encodings of the user input that the form processing server must accept in order to process the form. The value of this attribute is a comma-separated or space-separated list of IS0 character set names. The default value is
unknown, which the browser will interpret as the same character encoding that the page that contains the form is in. Based on this attribute, a browser may restrict the characters that are entered by the user in the form. However, none of the major browsers impose this restriction. The character encoding of the user input can be any one of those that are listed in theaccept-charsetattribute.Here is a list of character encodings http://www.w3schools.com/TAGS/ref_charactersets.asp
Example:
<form action="" accept-charset="ISO-8859-1,ISO-8859-2">actionThis is a required attribute. Its value is the URL of the web page or application that will process the form. If the value is left blank, then the browser submits the form to the current page.
Example:
<form action="contact.php">…</form>enctypeThis attribute specifies the content type used to submit the form to the server when the form uses
postto submit the form to the server (method=post). There are three possible values for theenctypeattribute:application/x-www-form-urlencodedThis is the default content type for
postand the only encoding ofget. With URL encoding, and thegetmethod, the following ASCII characters get encoded as shown in the table:Symbol URL-Encoded space + @ %40 # %23 $ %24 % %25 & %26 - %2B + %3D : %3A ; %3B , %2C ? %3F / %2F If the method is
post, in addition to the above mentioned characters, the following characters are encoded:Symbol URL-Encoded ~ %7E ` %60 ! %21 ^ %5E ( %28 ) %29 | %7C \ %5C { %7B [ %5B } %7D ] %5D " %22 < %3C , %2C > %3E text/plain- This encoding only converts spaces to "+" characters. This value has an effect only for
postrequests.getrequests are URL-encoded regardless of theenctypevalue. multipart/form-data- This Content Type is required when the form has a file upload form control. With this value, the form data is not encoded at all.
methodThis attribute specifies the method that will be used to submit the form data. It can take the following values:
get- This is the default when there is no
methodattribute or when it is blank. Withget, a question mark (?) is appended to the end of the URL of the form application and then the form data is appended. The form data consists of the value of thenameattribute followed by an equals sign and the data of the form control. Subsequent name-value pairs are separated by ampersands (&). The value of the form controls are URL-encoded. post- With this method the form data is sent as an HTTP
postrequest. When theenctypeisapplication/x-www-form-urlencoded, the form data is encoded as described earlier. When theenctypeistext/plainthe data is not encoded except for the space character which is encoded as the plus (+) character. When theenctypeismultipart/form-data, the form data is not encoded at all.
targetTransitional DTDs allow the
formtag to have thetargetattribute. With this attribute, you can specify the name of the window in which the form result should open.The
targetattribute is also useful in frame documents. Using this attribute, a form in one frame can show its results in another.Special Targets
There are four special
targetvalues:_blank- This target causes the form results to always open in a new window. The new window will not have an internal name.
_self- This target causes the form results to always load in the same window or frame as the form. This is the default behavior of forms.
_parent- This causes the form results to open in the parent of the document that contains the link. This is useful when using iframes.
_top- This causes the form results to open in the topmost frame in the hierarchy.

No comments:
Post a Comment