当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <label>标签
Defines a label to a control. If you click the text within the label element, it is supposed to toggle the control.
为空间定义lable。当你按了label中的文字,可以让文字与控件联系在一起
NONE
无
Note: The "for" attribute binds a label to another element. Set the value of the "for" attribute equal to the value of the "id" attribute of the related element.
注意:用"for"属性将label与另一个元素绑在一起。"for"属性值应该和相关的元素"id"属性值相同。
代码 | 输出结果 |
---|---|
<p>Try clicking on the text labels:</p> <form name="input" action=""><input type="radio" name="sex" id="male" /> <label for="male">Male</label> <br /> <input type="radio" name="sex" id="female" /> <label for="female">Female</label> </form> | Try clicking on the text labels: |
DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
下表中的DTD列指明了被支持的DTD属性。S=Strict(精确的),T=Transitional(传统的),F=Frameset(框架)
属性 | 值 | 描述 | DTD |
---|---|---|---|
for | id_of_another_field | Defines which form element the label is for. Set to an ID of a form element. label为表单中的哪个元素所定义。 Note: If this attribute is not specified, the label is associated with its contents. | STF |
id, class, title, style, dir, lang, xml:lang |
For a full description, go to Standard Attributes.
查看完整的属性
accesskey, onfocus, onblur, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup |
For a full description, go to Event Attributes.
查看完整的属性
Label
How to define a label to a control.
怎样为控件定义label