HTML <label> ਟੈਗ
定義と使用方法
<label>
ラベルは input 要素にアノテーション(タグ)を定義します。
ラベル要素はユーザーに特別な効果を表示しませんが、マウスユーザーのためのユーザビリティを向上させます。ラベル要素内のテキストをクリックすると、このコントロールがトリガーされます。つまり、ユーザーがこのラベルを選択すると、ブラウザが自動的にラベルに関連するフォームコントロールに焦点を合わせます。
<label>
ラベルの for 属性 関連する要素の id 属性と同じにする必要があります。
<label>
ラベルは複数の要素にタグ(マーク)を定義するために使用できます:
- <input type="checkbox">
- <input type="color">
- <input type="date">
- <input type="datetime-local">
- <input type="email">
- <input type="file">
- <input type="month">
- <input type="number">
- <input type="password">
- <input type="radio">
- <input type="range">
- <input type="search">
- <input type="tel">
- <input type="text">
- <input type="time">
- <input type="url">
- <input type="week">
- <meter>
- <progress>
- <select>
- <textarea>
上記の要素とラベルの正しい使い方は以下のユーザーに有益です:
- スクリーンリーダーユーザー(ユーザーが要素に焦点を合わせると、タグを読み上げます)
- 难以点击非常小的区域(例如复选框)的用户 - 因为当用户单击
<label>
元素中的文本时,它会切换输入(这增加了点击区域)
另请参阅:
HTML DOM 参考手册:Label 对象
提示和注释
提示:<label>
的 for 属性必须等于相关元素的 id 属性才能将它们绑定在一起。也可以通过将元素放置在 <label>
元素内将标签绑定到元素。
全局属性
<label>
标签还支持 HTML 中的全局属性。
事件属性
<label>
标签还支持 HTML 中的事件属性。
ਬਰਾਉਜ਼ਰ ਸਪੋਰਟ
ਚਰਮੇ | ਐਜ਼ | ਫਾਇਰਫਾਕਸ | ਸਫਾਰੀ | ਓਪਰਾ |
---|---|---|---|---|
ਚਰਮੇ | ਐਜ਼ | ਫਾਇਰਫਾਕਸ | ਸਫਾਰੀ | ਓਪਰਾ |
ਸਹਾਇਤਾ | ਸਹਾਇਤਾ | ਸਹਾਇਤਾ | ਸਹਾਇਤਾ | ਸਹਾਇਤਾ |