基于 for 属性的 CSS 目标标签?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13935064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:04:34  来源:igfitidea点击:

CSS target label based on for attribute?

csscss-selectors

提问by Evanss

Possible Duplicate:
CSS selectors - how to select ‘for' in CSS?

可能的重复:
CSS 选择器 - 如何在 CSS 中选择“for”?

I have the following html. Can I target the label based on its for attribute (so only target this label)?

我有以下 html。我可以根据它的 for 属性定位标签吗(所以只定位这个标签)?

<label for="something">Text</label> 

回答by Ladineko

You can target the attribute by :

您可以通过以下方式定位属性:

label[for="something"] {
   /* woohoo! */
}

Forstands for the attribute name
and ="value"stands for its value.

For代表属性名称
="value"代表它的值。