Match all elements having class name starting with a specific string

css

Solution

The following should do the trick:

div[class^='myclass'], div[class*=' myclass']{
    color: #F00;
}

Edit: Added wildcard (`*`) as suggested by David

Problem

Is it possible to use a "wildcard" for elements having a class name starting with a specific string in CSS3? Example: ``` <div class="myclass-one"></div> <div class="myclass-two"></div> <div class="myclass-three"></div> ``` and then magically set all the above `div`s to red in one go: ``` .myclass* { color: #f00; } ```

Original source

Related problems