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的值为val的元素,例如
- 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] 属性值选择符示例 -- 可以尝试编辑
浏览器兼容性
| 选择符 | IE6 | IE7 | IE8 | IE9 | FF | CH | OP | SA |
|---|---|---|---|---|---|---|---|---|
| E[att=val] | no | yes | yes | yes | yes | yes | yes | yes |