English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Directory

HTML: <form> tag

The HTML <form> tag is used to create a form on a web page with interactive controls for user input, used to submit information to a web server. This tag is also commonly referred to as the <form> element.

Online Example

HTML form with two input fields and a submit button:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 Use of footer tag (Basic Tutorial Website oldtoolbag.com)</title>/title>
</head>
<body
<h1>oldtoolbag.com Basic Tutorial</h1>
<form action="demo-form.php" method="post">
  Company: <input type="text" name="company"><br>
  Address: <input type="text" name="address"><br>
  <input type="submit" value="Submit">
</form>
</body>
</html>
Test to see ‹/›

In this HTML5In the document example, we used the <form> tag to create an HTML form. This form contains two <input> controls for company and address, as well as a submit button.

The effect after running is as follows:

Browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the <form> tag.

Points to note when using tags

If you set autocomplete to off in a form because the current document provides its own auto-complete, then you should also set autocomplete to off for each input element in the form to allow the document to take over auto-complete.

Tag definition and usage instructions

The <form> tag is used to create an HTML form for user input.

The <form> element contains one or more of the following form elements:

HTML 4.01 and HTML5Differences between

HTML5 Two new attributes have been added: autocomplete and novalidate, and HTML is no longer supported. 4.01 of some attributes.

Differences between HTML and XHTML

In XHTML, the name attribute has been deprecated. Use the global id attribute instead.

Attribute

New: HTML5 of the new attribute.

AttributeValueDescription
acceptMIME_typeHTML5 Not supported. Specifies the type of files the server can receive. (Files are submitted through file upload)
accept-charsetcharacter_setSpecifies the character set that the server can handle for form data.
actionURLSpecifies where to send the form data when the form is submitted.
autocompleteHTML5on
off
Specifies whether the form's auto-complete feature is enabled.
enctypeapplication/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how to encode the form data before sending it to the server. (Applicable when method="post")
methodget
 post
Specifies the HTTP method to be used for sending form data.
nametextSpecifies the name of the form.
novalidateHTML5novalidateIf this attribute is used, the form will not be validated when submitted.
target_blank
 _self
 _parent
 _top
Specifies where to open the action URL.

Global Attributes

Support for <form> tag Global Attributes of HTML.

Event Attributes

Support for <form> tag HTML Event Attributes.

Try Online Example

Radio Buttons
This example demonstrates how to create radio buttons in HTML.

Checkboxes
This example demonstrates how to create checkboxes in an HTML page. Users can select or deselect checkboxes.

Simple Dropdown List
This example demonstrates how to create a simple dropdown list box in an HTML page. A dropdown list box is an optional list.

Pre-selected Dropdown List
This example demonstrates how to create a simple dropdown list with pre-selected values.

Textarea
This example demonstrates how to create a textarea (multi-line text input control). Users can write text in the textarea. There is no limit to the number of characters that can be written.

Create Button
This example demonstrates how to create a button. You can customize the text on the button.

Related Articles

HTML Tutorial:HTML Forms and Inputs

HTML DOM Reference Manual: Form Object