HTML5 <label> 标签

定义和用法

<label> 标签定义控件的标注。如果您在 label 元素内点击文本,就会触发此控件。就是说,当用户选择该标签时,浏览器就会自动将焦点转到和标签相关的表单控件上。

HTML 4.01 与 HTML5 之间的差异

没有。

提示和注释

注释:"for" 属性可把 label 绑定到另外一个元素。请把 "for" 属性的值设置为相关元素的 id 属性的值。

属性

属性 描述 4 5
for id_of_another_field

定义 label 针对哪个表单元素。设置为表单元素的 id。

注释:如果此属性未被规定,那么 label 会关联其内容。

4 5

标准属性

class, contenteditable, contextmenu, dir, draggable, id, irrelevant, 
lang, ref, registrationmark, tabindex, template, title

如需完整的描述,请访问 HTML5 中标准属性

事件属性

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, 
ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, 
ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, 
onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, 
onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

如需完整的描述,请访问 HTML5 中事件属性

TIY 实例

label
如何为控件定义标记。

Copyright © 2009-2011 HTML5中文网 版权所有