- HTML中文网
- 联系QQ:88526
- QQ交流群

- 微信公众号

[attribute~=value] 选择器
定义和用法
[attribute~=value] 选择器用于选择属性值包含一个指定单词的元素。
浏览器支持
所有主流浏览器都支持[attribute~=value]选择器。
注意:[attribute~=value]在IE8中运行,必须声明 <!DOCTYPE>。
选择标题属性包含单词"flower"的所有元素:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> img[title~=flower]{ border:5px solid yellow; } </style> </head> <body> <div> <h3>img标签的 title 属性中如果带有 "flower" 单词,则会设置为黄色边框。</h3> <img src="1.jpg" title="klematis flower" width="200" height="112" /> <img src="2.jpg" title="flowers" width="200" height="112" /> <img src="3.jpg" title="landscape" width="200" height="112" /> </div> </body> </html>
点击 "运行实例" 按钮查看在线实例
效果图:
推荐手册