The [attribute=value]
selector selects
elements with the specified attribute and value.
element1[attr="value"]
is also called Exact Attribute Value Selector.
element1[attr="value"]
selects any element based on
the precise and complete value of an attribute.
Examples:
a[rel="Start"] {font-weight: bold;} p[class="urgent"] {color: red;}
[attribute=value] { style properties }
[attribute=value] |
Yes | 7.0 | Yes | Yes | Yes |
An example showing how to use [attribute=value] CSS selector.
<!DOCTYPE html>
<html>
<head>
<style>
a[target=_blank]<!-- www. j a v a 2s . co m-->
{
background-color:red;
}
</style>
</head>
<body>
<a href="http://java2s.com" target="_top">java2s.com</a>
</body>
</html>