Using CSS, you can apply multiple styles to one HTML element. This is obvious and helps to keep our HTML and CSS clean and redundant. What happens if we want to style the element differently ONLY if two different classes applied?
demo
It is nothing special and new that we are allowed to apply multiple CSS styles to one HTML element. It helps to keep our CSS clear and clean and can reduce our CSS size drastically. This can be accomplished as shown below:
Situation gets more complicated if we would like to style the element differently ONLY if two classes are applied. CSS multiple class styling with the different style on multi-class elements.
CSS styles looks like this:
Our HTML reads:
The effect is obvious:

Basicly if the element have .background and .border classes assigned to itself, we would like to change the color. And another element, if 3 classes are assigned we would like to add uppercase styling.
Add this to our existing CSS:
And add 2 more DIV tags:
Our final result:

This is it! I hope you liked it. Don’t forget to share and comment below!
Latest Tweets
Partners
Resources
Become a Guest Author
About the Blog Author