HTML Form Attributes
The different attributes for the HTML <form> element.
The Action Attribute
The action attribute contains the URL of the server program that will process the contents of the form.
Some browsers also might support a mailto URL, which can mail the results to the specified address.
Otherwise, the delivery of the data in the form is defined by the method attribute.
This example shows how to use action attribute:
Example
<form action="action">
The Target Attribute
The target attribute specifies the target frame that will display the results of a form submission.
In addition to named frames, several special values exist.
The _blank value indicates a new window.
The _parent value indicates the parent frame set containing the source link.
The _self value indicates the frame containing the source link.
The _top value indicates the full browser window.
The frameName value indicates the a iframe.
Example
<form target="_blank" action="action">
The Method Attribute
The method attribute specifies how form information should be transferred to the server using a particular HTTP method.
A get value in the attribute specifies that form data should be appended to the URL specified by the action attribute, thus creating a query string. But it imposes a size limitation variation between browser.
A value of post for this attribute transfers the data of the form in the message body using the HTTP POST method which imposes no data size limitation.
Example
<form action="action" method="get">
The POST method must be used when file attachments are used in a form.
| Value | Description |
|---|---|
| get | The GET method form data appended to the action URL with a ? separator. Use this method when the form has no side-effects. |
| post | The POST method form data sent as the request body. |
| dialog (new) | When the form is inside a <dialog>, closes the dialog on submission. |
All <form> Attributes
| Attribute | Value | Description |
|---|---|---|
| accept-charset | characterSet | Specifies the list of character encodings for input data that must be accepted by the server processing the form. |
| action | URL | action attribute contains the URL of the server program that will process the contents of the form. |
| autocomplete | on off |
autocomplete attribute, will automatically finish filling in information that the user has previously input into an input field. |
| enctype | application/x-www-form-urlencoded multipart/form-data text/plain |
enctype attribute specifies how form data should be encoded before being sent to the server. |
| method | get post |
method attribute specifies how form information should be transferred to the server using a particular HTTP method. |
| name | text | name attribute specifies a name for the form and was traditionally used by JavaScript or other client-side programming technologies to reference forms and their contained elements. |
| novalidate | novalidate | novalidate is Boolean attribute determines whether or not form validation should be applied on the elements within. |
| rel | external help license next nofollow noopener noreferrer opener prev search |
Specifies the relationship between a linked resource and the current document |
| target | _blank _self _parent _top |
target attribute specifies the target frame that will display the results of a form submission. |