CSS3 [attribute$=value] Selector

Example

Set a background color on all div elements that have a class attribute value that ends with "test":

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

Try it yourself »

Definition and Usage

The [attribute$=value] selector matches every element whose attribute value ends with a specified value.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The [attribute$=value] selector is supported in all major browsers.

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


Examples

Try it Yourself - Examples


Example

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

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

Try it yourself »