Selector by one of attribute values
The selector by one of the attribute values sets the style for an element that has at least one of the specified values in the attribute. In this case, all attribute values must be separated by a space.
Example
Let's find all <p> that contain
test in one of their values and
recolor them blue:
<p class="test main">text1</p>
<p class="text">text2</p>
<p class="tag test">text3</p>
p[class~="test"] {
color: blue;
}
:
See also
-
an attribute selector
that searches for an element by attribute name -
an attribute selector
that searches for an element by attribute value -
an attribute selector
that searches for an element based on the start of an attribute value -
an attribute selector
that searches for an element based on the end of an attribute value -
an attribute selector
that searches for an element by text in an attribute value -
an attribute selector
that searches for an element by a hyphen in an attribute value -
the child selector
that allows you to select elements by direct nesting -
the descendant selector,
that allows you to select an element by its parent -
the adjacent sibling selector
that allows you to select an element by its sibling -
the general sibling selector
that allows you to select elements after a given -
the universal selector
that allows you to select all elements