网络学院 w3pop社区 网络资源 IT新闻

w3pop.com :: 网络学院 :: HTML :: HTML <label>标签

会员登陆

帐号

密码

回答

记住密码

忘记密码? 注册

HTML <label>标签


作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-28 浏览:2225 :: ::

定义和用法

Defines a label to a control. If you click the text within the label element,  it is supposed to toggle the control.
为空间定义lable。当你按了label中的文字,可以让文字与控件联系在一起


在HTML和XHTML中的区别

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.
注意:如果这个属性没有指明,label会关联到它的内容

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

评论 (0) All