How to use CSS attribute equal Selector [attribute=value]

Description

The [attribute=value] selector selects elements with the specified attribute and value.

Example


<!DOCTYPE html>
<html>
<head>
<style>
a[target=_blank]<!--from   w ww  .java 2s.  c o m-->
{
   background-color:red;
}
</style>
</head>
<body>

<a href="http://java2s.com" target="_top">java2s.com</a>

</body>
</html>

Click to view the demo

The code above generates the following result.

[attribute=value]




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference