如何设置“标签”HTML元素的ID? [英] How to set the id of a 'label' HTML element?

查看:150
本文介绍了如何设置“标签”HTML元素的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有以下内容:

 < label for =deletetxt>删除此文本< / label> 

这里的'for'属性是什么?假设我不能为标签元素设置类来设计标签元素,我该如何设置这个元素的css?

解决方案

两个问题,两个答案:


  1. 这里的'for'属性是什么?



    这里告诉< input>的标识符标签引用的元素。当用户点击< LABEL> 时,某些浏览器将使用它来关注< input>


  2. 我如何为这个元素设置css?



    如果你想CSS的所有标签元素:





 标签{
/ *您的款式* /
}




B。如果您想标记该元素,则只需使用ID或类名即可。


If I have the following:

             <label for="deletetxt">Delete This Text</label>

What is the 'for' attribute here? Is that the id?

Assuming that I cannot set a class for the label element to style the label element, how do i set css for this element?

解决方案

Two question, two answers:

  1. What is the 'for' attribute here?

    It's here to tell the ID of the <input> element that label refers to. Some browsers will use it to set focus on that <input> element when user clicks on that <LABEL>

  2. how do i set css for this element?

    A. If you want to CSS all label elements :

      label {
         /* your styles */
      }

B. If you want to label that element, just use IDs or classnames as you usually do.

这篇关于如何设置“标签”HTML元素的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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