Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

<form>

<form
accept-charset=charset
action=url
class=type
dir=ltr|rtr
enctype=string
id=value
lang=language
method=get|post
name=name
style=style
target=name
title=text
</form>

Denotes a form.

You must enter the end-tag.

Attributes

accept-charset=charset

Specifies a list of character encodings that are accepted by the form

action=url

The action attribute is a URL specifying the location to which the contents of the form data fields are submitted to elicit a response. This might simply be a direction to an e-mail address, but generally, would be used to point towards some kind of server based CGI script/application that handles the forwarding of form data. If you don’t specify a URL, the browser uses the base URL of the page.

The way data is submitted varies with the access protocol of the URL to which the form data is sent and with the values of the method and enctype attributes

class=type

Indicates the class to which the tag belongs. You can use the class attribute in a style sheet to create different styles that you want apply to a single HTML tag. For example, you might create three different styles for a <form> tag. See Using the class attribute as a selector for more details.

dir=ltr|rtr

Specifies the direction of text. This can be left-to-right (ltr) or right-to-left (rtl). For example, English characters are presented left-to-right, Hebrew characters are presented right-to-left.

enctype=string

Specifies the media type used to encode the form data. The default enctype is the MIME type 'application/x-www-form-urlencoded'

id=value

Specifies a unique name for the tag. No two tags can have the same id on a single page. The value must begin with a letter followed by any alphanumeric character, a hyphen, an underscore, a colon or a full stop. You use it to reference a unique style for a tag or to manipulate the tag with a script.

lang=language

Specifies which language the <form> tag uses. You can enter any valid ISO standard language abbreviation, for example, “en” for English, “de” for German and so on. For example, <span lang="es">hola! como esta?</span>.

This attribute helps search engines understand different languages as different languages rather than just misspelled English. It may also help spelling and grammar checkers and allow speech synthesizers to use language-dependent pronunciation rules.

method=get|post

Indicates how the form data should be sent to the server. The default is get.

Value…

Description…

get

Appends the arguments to the action URL and opens it as if it were an anchor

post

Sends the data via an HTTP post transaction

The get method is ideal for form submission where the use of the form data does not require external processing. For example, with database searches, there is no lasting effect caused by the query of the form (that is, the query runs its search through the database and reports the results).

However, where the form is used to provide information for example, that updates a database, then the post method should be used, with the action attribute pointing to a CGI script that executes the form data processing.

name=name

The name of the element for scripting purposes.

style=style

Specifies style information. See Style sheets for more information.

target=name

You can associate a name with browser windows and frames that links can refer to. When you click on the link, the browser displays the destination page in the named window or frame. Only supported by browsers that can handle frames.

The target can be one of the following:

Value…

Description…

name

Loads the link into the window or frame with this name. The name must begin with an alphanumeric character

_blank

Load page into a new blank window

_parent

Load the page into the immediate parent of the page

_self

Load the page into the current window

_top

Load the page into the full body of the window

title=text

For information only. Some browsers display the title when you move the mouse over the tag (like a tool tip).