HTML <form> Tag

Advertisements


Description

The HTML <form> tag is used for creating a form for user input. A form can contain textfields, checkboxes, radio-buttons and more. Forms are used to pass user-data to a specified URL.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML form Tag</title>
</head>
<body>
<form action="/cgi-bin/hello_get.cgi" method="get">
First name: 
<input type="text" name="first_name" value="" maxlength="100" />
<br />
Last name: 
<input type="text" name="last_name" value="" maxlength="100" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

This will produce following result:

First name:
Last name:

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <form> tag also supports following additional attributes:

AttributeValueDescription
acceptMIME_type Specifies a comma-separated list of content types that the server accepts.
accept-charsetcharset listSpecifies a list of character encodings that the server accepts. The default value is "unknown".
action URLSpecifies a URI/URL of the back-end script that will process the form
autocompletehtml-5on
off
Specifies whether form should have autocomplete on or off
enctype mimetypesThe mime type used to encode the content of the form.
method get
post
Specifies 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)
nameform nameDefines a unique name for the form.
novalidate html-5novalidateSpecifies that the form should not be validated when submitted.
target_blank
_self
_parent
_top
Target to open the given URL.
_blank - the target URL will open in a new window
_self - the target URL will open in the same frame as it was clicked
_parent - the target URL will open in the parent frameset
_top - the target URL will open in the full body of the window

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm