Using a Wildcard Selector (*) in CSS and Excluding Some Tags

Using a Wildcard Selector (*) in CSS and Excluding Some Tags

You might run into the situation where a plug-in, theme or your own design requires you to have a wild card selector in your CSS to set all of your elements to a certain format. So you might see something like this:

* { /* Some CSS in here */}

But there might be a certain tag that you need to exclude because your wild card has had unexpected interactions with the rest of your design.

A quick and dirty fix is that, you can exclude entire tags from your wild card with a not statement used like if I wanted to exclude all spans:

*:not(span) { /* Some CSS in here */}

This will exclude spans from the wild card and whatever other tags or elements you may want to include in it. You can also go and add additional lines of CSS to style those tags correctly or rework your design so that you don’t need a blanket wild card.

Leave a Reply

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