CSS [attribute$="value"]
selector selects all the elements whose attribute value ends with the specified value. The ending value needs not be a whole word.
The [attribute$=”value”] selector in the example below selects all the <a>
elements whose href
attribute ends with a value '.com'
and sets their background color to yellow.
Example:
a[href$=".com"]{ background: yellow; }
Select all the <p>
elements whose class
attribute ends with a value ‘center’ and set their text alignment to center.
Example:
p[class$="center"]{ text-align: center; }
CSS Syntax
The [attribute$=”value”] selector has the following syntax:
[attribute$="value"]{ CSS styles }
Related Pages
CSS Tutorials: CSS Attribute Selectors