CSS3/Selectors/attribute selector/attribute=value

From W3C Wiki

[attributename="val"]

This selector represents an element with the "attributename" attribute whose value is exactly "val".

Syntax

elementname[attributename="val"]{ properties }

Example

In the following example, the selector represents a span element whose class attribute has exactly the value "example":

[style.css]

 span[class="example"]{
   color: red;
   font-size: 1.2em;
 }

[index.html]

<body>
  <p>This is a <span class="example">paragraph</span>.</p>
  <p>This is a <span class="test">paragraph</span>.</p>
</body>

The CSS Selectors Level 3 specification defines the attribute selector in 6.3.1. Attribute presence and value selectors.