If more than one rule set is applied to an element, the rule set with the selector that has the highest specificity is used. In html and css every selector has its specificity. For example:
p - has specificity 1
if it's div p, then specificity would be 2
class selectors usually have specificity 10.
and so on