CSS/Selectors/attribute selector/attribute=value

From W3C Wiki
< CSS‎ | Selectors
Jump to: navigation, search


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


elementname[attributename="val"]{ properties }


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


   color: red;
   font-size: 1.2em;


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

Css3 selectors att 002.png

CSS defines the attribute selector in 6.3.1. Attribute presence and value selectors.