HTML and form
You can transfer data to the server using the label, which is used as follows:HTML form with two input fields and a submit button:
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
</form>
Try it out . . .
(See bottom of page for more examples)
Browser support
All major browsers support the label.
Label definition and instructions for use
The label is used to create HTML forms for user input. You can simply add a form in the programming battle of this site.
The element contains one or more of the following form elements:
The difference between HTML 4.01 and HTML5
HTML5 adds two new properties: autocomplete and novalidate, and no longer supports some properties in HTML 4.01.
The difference between HTML and XHTML
In XHTML, the name property has been discarded. Use the global id property instead.
Property
New : The new property in HTML5.
属性 | 值 | 描述 |
---|---|---|
accept | MIME_type | HTML5 不支持。 规定服务器接收到的文件的类型。(文件是通过文件上传提交的) |
accept-charset | character_set | 规定服务器可处理的表单数据字符集。 |
action | URL | 规定当提交表单时向何处发送表单数据。 |
autocomplete New |
on
off |
规定是否启用表单的自动完成功能。 |
enctype |
application/x-www-form-urlencoded
multipart/form-data text/plain |
规定在向服务器发送表单数据之前如何对其进行编码。(适用于 method="post" 的情况) |
method |
get
post |
规定用于发送表单数据的 HTTP 方法。 |
name | text | 规定表单的名称。 |
novalidate New | novalidate | 如果使用该属性,则提交表单时不进行验证。 |
target |
_blank
_self _parent _top |
规定在何处打开 action URL。 |
Global properties
Labels support the global properties of HTML.
The event property
The tag supports the event properties of HTML.
Try it - instance
A form with a check box
This form contains two check boxes and a submit button.
A form with a turntable button
This form contains two check boxes and a submit button.
Related articles
HTML tutorial: HTML forms and inputs
HTML DOM Reference Manual: Form Object