CSS [attribute~=value] Selector
Example
Select and style all elements with a title attribute that contains a space-separated list of words, one of which is "flower":
[title~="flower"]
{
background-color: yellow;
}
Try it Yourself »
Definition and Usage
The [attribute~=value] selector is used to select elements with an attribute value containing a specified word.
The example above will match elements with title="flower", title="summer flower", and title="flower new", but not title="my-flower" or title="flowers".
Version: | CSS2 |
---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the selector.
Selector | |||||
---|---|---|---|---|---|
[attribute~=value] | 4.0 | 7.0 | 2.0 | 3.1 | 9.6 |
CSS Syntax
Related Pages
CSS tutorial: CSS Attribute Selectors
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.