HTML 5 <label> 標簽
定義和用法
<label> 標簽定義控件的標注。如果您在 label 元素內(nèi)點擊文本,就會觸發(fā)此控件。就是說,當用戶選擇該標簽時,瀏覽器就會自動將焦點轉到和標簽相關的表單控件上。
HTML 4.01 與 HTML 5 之間的差異
沒有。
提示和注釋
注釋:"for" 屬性可把 label 綁定到另外一個元素。請把 "for" 屬性的值設置為相關元素的 id 屬性的值。
屬性
屬性 | 值 | 描述 | 4 | 5 |
---|---|---|---|---|
for | id_of_another_field |
定義 label 針對哪個表單元素。設置為表單元素的 id。 注釋:如果此屬性未被規(guī)定,那么 label 會關聯(lián)其內(nèi)容。 |
4 | 5 |
標準屬性
class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title
如需完整的描述,請訪問 HTML 5 中標準屬性。
事件屬性
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
如需完整的描述,請訪問 HTML 5 中事件屬性。
TIY 實例
- label
- 如何為控件定義標記。