Daniel Williams Daniel Williams - 5 months ago 27
CSS Question

Applying rules to multiple classes using a * match

My class names generate dynamically and I'm trying to apply styling to them using a kind of preg_match. Is something like this possible?

.*_class {
border: 1px solid red;

<div id="a_class">a</div>
<div id="b_class">b</div>
<div id="c_class">c</div>


You need to use attribute selectors for this.

[class$="_class"] {


The above says, anything with a class that ends with _classs should be selected. For more information, see Attribute Selectors.