What do multiple css classes do?


My application uses multiple classes using CSS modules.

open is a boolen variable to determine if Paper should shift or not.

        <Paper className={`${classes.paper} ${open && classes.paperShift}`}>

Question: Why are multiple classes being used, and how can they render differing results?

Note, I looked at this other post: using css modules how do I define more than one style name


The rules of each CSS class are simply combined together by the browser and all the rules are applied to the element. (If any of the rules contradict each other, the browser will decide which has precedence – if you learn more about CSS you can start to understand how that works in detail).

So, multiple classes can be used to apply various different styles to an element at the same time. Those rules might be split up into different classes to make the visual design more flexible and the rules more re-usable.

Classes defined on an element can potentially also be used by JavaScript code to select certain elements (or groups of elements) in order to perform actions on them or get information from them.

Answered By – ADyson

Answer Checked By – Marilyn (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.