HTML 4 form Tag

Also see HTML5 <form> Tag.

This page is for the HTML 4 version of this element. For a more up to date version, see HTML5 <form> Tag.


The HTML form tag is used for declaring a form.

The <form> tag is used in conjunction with form-associated elements. To create a form, you can nest form-associated elements inside the opening/closing <form> tags.

Form-Associated Elements

Here are the elements that you can use with your forms.

These elements allow the user to provide information to the website - information which can be submitted to the server for processing.

HTML 5 gives forms the ability to have improved functionality. For example, a form element can contain the form attribute to bind itself to a form. HTML 5 also introduces the <datalist> element. For more information, see the HTML 5 <form> element.

Example

Attributes

Attributes specific to this tag:
AttributeDescription
actionSpecifies a URI/URL of the page that will process the form.
methodSpecifies the HTTP method to use when the form is submitted. Possible values:
  • get (the form data is appended to the URL when submitted)
  • post (the form data is not appended to the URL)
enctypeSpecifies the content type used to encode the form data set when it's submitted to the server. Possible values:
  • application/x-www-form-urlencoded (default)
  • multipart/form-data (use this when uploading files)
accept-charsetSpecifies a list of character encodings that the server accepts. The default value is "UNKNOWN".
acceptSpecifies a comma-separated list of content types that the server accepts.
nameAssigns a name to the form. This is used when referencing the form with stylesheets or scripts. If there are multiple forms, the name of each form must be unique.
Other Attributes:
AttributeDescription
classDocument wide identifier.
idDocument wide identifier
dirSpecifies the direction of the text
langLanguage code
targetSpecifies the target frame to load the destination page as indicated with the action attribute.
onSubmitIntrinsic event (see event handlers)
onResetIntrinsic event (see event handlers)
onclickIntrinsic event (see event handlers)
ondbclickIntrinsic event (see event handlers)
onmousedownIntrinsic event (see event handlers)
onmouseupIntrinsic event (see event handlers)
onmouseoverIntrinsic event (see event handlers)
onmousemoveIntrinsic event (see event handlers)
onmouseoutIntrinsic event (see event handlers)
onkeypressIntrinsic event (see event handlers)
onkeydownIntrinsic event (see event handlers)
onkeyupIntrinsic event (see event handlers)

HTML5 Tags

The information on this page is based on HTML version 4.01. Most modern browsers now support HTML5.

See HTML5 <form> Tag for the HTML5 version of the above element.

See this list of HTML tags for the latest list of HTML elements.