14.9.2 CSS E[att=val] 属性值选择符

E[att=val] -- CSS E[att=val] 属性值选择符,匹配文档中具有att属性且其值为val的E元素
  • 语法: E[att=val]
    • E -- 元素
    • att -- 属性
    • val -- 属性值
  • 引用网址:http://www.dreamdu.com/css/selector_attribute_values/
  • 说明:
    • 匹配文档中元素的属性att的值为val的元素,例如a[title=dreamdu]选择符,表示具有title属性且其值为dreamdu的a元素
  • att,是attribute的缩写,中文"属性"。val,是value的缩写,中文"值"

示例

a[title="dreamdu"]
{
	color:red;
}

input[type="text"]
{	
	background: green;
	color: white;
	border: 1px solid blue;
}

input[type="password"]
{	
	background: blue;
	color: white;
	border: 1px solid green;
}

所有title值为dreamdu的a标签的文字颜色将显示红色

属性值选择符也可以匹配多个属性,例如:

*[title="dreamdu"][href="http://www.dreamdu.com/"]
{
	color: pink;
	border: 1px solid blue;
}

只有title为dreamdu和href为http://www.dreamdu.com/的标签,文字才显示粉色

CSS E[att=val] 属性值选择符示例 -- 可以尝试编辑

浏览器兼容性

CSS E[att=val] 属性值选择符浏览器兼容性
选择符 IE6 IE7 IE8 IE9 FF CH OP SA
E[att=val] no yes yes yes yes yes yes yes


  • 教程中有什么不懂的地方?发现教程的错误!对教程有什么建议!快快给我留言呀 给猴子留言,我会尽快解答你的问题:)
  • HTML代码