English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
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:
IEFirefoxOperaChromeSafari
All mainstream browsers support the <form> tag.
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.
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:
HTML5 Two new attributes have been added: autocomplete and novalidate, and HTML is no longer supported. 4.01 of some attributes.
In XHTML, the name attribute has been deprecated. Use the global id attribute instead.
New: HTML5 of the new attribute.
Attribute | Value | Description |
---|---|---|
accept | MIME_type | HTML5 Not supported. Specifies the type of files the server can receive. (Files are submitted through file upload) |
accept-charset | character_set | Specifies the character set that the server can handle for form data. |
action | URL | Specifies where to send the form data when the form is submitted. |
autocompleteHTML5 | on off | Specifies whether the form's auto-complete feature is enabled. |
enctype | application/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") |
method | get post | Specifies the HTTP method to be used for sending form data. |
name | text | Specifies the name of the form. |
novalidateHTML5 | novalidate | If this attribute is used, the form will not be validated when submitted. |
target | _blank _self _parent _top | Specifies where to open the action URL. |
Support for <form> tag Global Attributes of HTML.
Support for <form> tag HTML Event Attributes.
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.
HTML Tutorial:HTML Forms and Inputs
HTML DOM Reference Manual: Form Object