<form>
HTML <form> Tag
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <form action="demo-form.php"> First name: <input type="text" name="FirstName" value="Mickey"><br> Last name: <input type="text" name="LastName" value="Mouse"><br> <input type="submit" value="提交"> </form> <p>点击"提交"按钮,表单数据将被发送到服务器上的“demo-form.php”。</p> </body> </html>
Run Example»
Click the "Run Instance" button to view the online instance
Browser support
All major browsers support the <form> tag.
Tag definition and usage instructions
<form> tag is used to create HTML forms for user input. The
<form> element contains one or more of the following form elements:
<input>
- ##< ;textarea>
- <button>
- <select> ##<option> ;
- <optgroup>
- <fieldset>
- <label>
HTML5 adds two new attributes: autocomplete and novalidate, and no longer supports HTML 4.01 certain properties.
Differences between HTML and XHTMLIn XHTML, the name attribute has been deprecated. Use the global id attribute instead.
AttributeNew
: New attribute in HTML5.
Value | Description | |
---|---|---|
MIME_type | HTML5 is not supported. | Specifies the type of file received by the server. (Files are submitted via file upload) |
character_set | Specifies the form data that the server can process character set. | |
URL | Specifies where to send form data when the form is submitted. | |
on | offSpecifies whether to enable the autocomplete function of the form. | |
application/x-www-form-urlencoded | multipart/form-data
text/plain Specifies how to encode form data before sending it to the server. (Applicable to method="post") | |
get | PostSpecifies the HTTP method used to send form data. | |
text | Specifies the name of the form. | |
novalidate | If this attribute is used, no validation will be performed when submitting the form. | |
_blank | _self
_parent _top specifies where to open the action URL. |