Categories
CSS

How to use wildcard * in CSS for classes?

Spread the love

To use wildcard * in CSS for classes, we use attribute selectors.

For instance, we write

div[class^="tocolor-"],
div[class*=" tocolor-"] {
  color: red;
}

to select divs with clas starting with tocolor- with div[class^="tocolor-"].

And we select divs with clas starting including tocolor- with div[class*="tocolor-"].

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *