CSS3 [attribute*=value] Selector

Definition and Usage

CSS [attribute*=value] The selector is used to match each element that contains the specified value in the attribute value.

Example

Example 1

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

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

Try It Yourself

Example 2

Set styles for all elements with class attribute values containing "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