表示帶有以 attribute 命名的屬性,且屬性值為"value"的元素。
選擇所有使用target="_blank"的a元素
<!DOCTYPE html>
<html>
<title>菜鳥教程(cainiaoplus.com)</title>
<head>
<style>
a[target=_blank]
{
background-color:blue;
color:#ffffff;
}
</style>
</head>
<body>
<p>帶有 target 屬性的鏈接將被填充藍(lán)色背景:</p>
<a href="//www.jixiangtaizi.com.cn">(cainiaoplus.com)</a>
<a href="//www.baidu.com" target="_blank">baidu.com</a>
<a href="//www.pcjson.com" target="_top">pcjson.com</a>
<p><b>注意</b> 為了使[<i> attribute </i>]在IE8及更早版本中運(yùn)行,必須聲明DOCTYPE。</ p>
</body>
</html>測(cè)試看看 ?/?[attribute=value] 選擇器用于選擇指定了屬性和值的元素。
IEFirefoxOperaChromeSafari
所有主流瀏覽器都支持[attribute=value]選擇器。
注意: [attribute=value] 在IE8中運(yùn)行,必須聲明 <!DOCTYPE>
CSS 教程: CSS 屬性選擇器