May 03, 2021 HTML5
HTML5 is used to tag input elements.
A simple HTML form with two input fields and related tags:
<form action="demo_form.asp">
<label for="male">Male</label>
<input type="radio" name="sex" id="male" value="male"><br>
<label for="female">Female</label>
<input type="radio" name="sex" id="female" value="female"><br>
<input type="submit" value="提交">
</form>
Most browsers currently support the hashtag.
The label defines labels (tags) for input elements.
Label elements do not render any special effects to the user. H owever, it improves availability for mouse users. T his control is triggered if you click on the text within the label element. That is, when the user selects the label, the browser automatically turns the focus to the label-related form control.
The for property of the label should be the same as the id property of the related element.
Tip: The "for" property binds the label to another element. Set the value of the "for" property to the value of the id property of the related element.
The "form" property is a new property of HTML5.
New: HTML5 new property.
Property | Value | Describe |
---|---|---|
for | element_id | Specifies which form element the label is bound to. |
form New | form_id | Specifies one or more forms to which the label field belongs. |
The label supports global properties and views the full property sheet HTML global properties.
The label supports all HTML event properties.