CSS3 [attribute*=value] Selector


Example

Set a background color on all <div> elements that have a class attribute value containing "test":

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

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The [attribute*=value] selector matches every element whose attribute value containing a specified value.

Version: CSS3


Browser Support

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

Selector
[attribute*=value] 4.0 7.0 3.5  3.2 9.6

Note: For this selector to work in IE8 and earlier, a <!DOCTYPE> must be declared.


CSS Syntax

attribute *= value {
    css declarations;
} Demo


Examples

More Examples


Example

Set a background color on all elements that have a class attribute value containing "test":

[class*="test"] {
    background: #ffff00;
}

Try it yourself »


Related Pages

CSS tutorial: CSS Attribute Selectors



Color Picker

colorpicker