English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules

Comprehensive CSS Properties

CSS [attribute=value] selector

Represents elements that have an attribute named 'attribute' with a value of 'value'.

Complete CSS Selector Reference Manual

Online Example

Select all a elements using target="_blank"

!DOCTYPE html
<html>
<title>Basic Tutorial Website(oldtoolbag.com)</title>
<head>
<style>
a[target=_blank]
{
background-color:blue;
color:#ffffff;
}
</style>
</head>
<body>
<p>Links with the target attribute will be filled with a blue background:</p>
<a href="//www.oldtoolbag.com">oldtoolbag.com</a>
<a href="//www.baidu.com" target="_blank">baidu.com</a>
<a href="//www.pcjson.com" target="_top">pcjson.com</a>
<p><b>Attention</b> To make[<i> attribute </i>] in IE8and earlier versions must declare DOCTYPE.</ p>
</body>
</html>
Test to see ‹/›

Definition and Usage

[attribute=value] selector is used to select elements that have specified attributes and values.

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support[attribute=value] selector.

Note:  [attribute=value] in IE8must be declared to run in <!DOCTYPE>

Related Articles

CSS Tutorial: CSS Attribute Selector

Complete CSS Selector Reference Manual