什么是“……"?用于标签标签? [英] What's the "for" for in a label tag?

查看:59
本文介绍了什么是“……"?用于标签标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需遇到HTML标签标记中的 for 参数:

Just ran across a for parameter in an HTML label tag:

<label for="required-firstname"> First Name </label>
<small>*</small>
<input name="required-firstname" type="text" tabindex="2" 
       id="required-firstname" size="24" maxlength="40">

我正在将这种形式转换为PHP处理的脚本,我可以摆脱for =参数吗?(出于好奇,它是做什么的?)

I'm converting this form to a PHP processed script, can I get rid of the for= parameters? (And out of curiosity, what does it do?)

推荐答案

来自w3schools.org:

From w3schools.org:

标签为输入元素定义标签.

The tag defines a label for an input element.

label元素不会呈现为用户的任何特殊内容.但是,它为鼠标用户提供了可用性改进,因为如果用户单击label元素内的文本,则会切换控件.

The label element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the label element, it toggles the control.

标记的for属性应等于相关元素的id属性,以将它们绑定在一起.

The for attribute of the tag should be equal to the id attribute of the related element to bind them together.

HTH!

将我的$ .02美元添加为可访问性中小型企业-以及可用性,LABEL还将输入字段与正确的标签相关联,以便使用屏幕阅读器的人员将知道该字段的用途.

adding my $.02 as an Accessibility SME - as well as usability, the LABEL also associates the input field with the correct label so persons using screen readers will know what the field is for.

这篇关于什么是“……"?用于标签标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆