CSS3 [attribute$=value] Selector

Definition and Usage

CSS [attribute$=value] The selector is used to match each element whose attribute value ends with the specified value.

Example

Example 1

Set styles for all <div> elements with class attribute values ending with "test":

div[class$="test"] {
  background: salmon;
}

Try It Yourself

Example 2

Set styles for all elements with class attribute values ending with "test":

[class$="test"] {
  background: salmon;
}

Try It Yourself

CSS Syntax

[attribute $= value] {
  css declarations;
}

Technical Details

Version: CSS3

Browser Support

The numbers in the table indicate the first browser version that fully supports this selector.

Chrome Edge Firefox Safari Opera
4.0 7.0 3.5 3.2 9.6

Related pages

CSS Tutorial:CSS attribute selector

CSS Tutorial:Detailed Explanation of CSS Attribute Selectors