Cascading is the process by which CSS handles when two or more rules target the same element. CSS adds an order of importance to each rule as follows:
Rules are ordered by how specific the selector is. More specific selectors override those with less specific ones. If two rules are equally specified, the last rule will be applied.
In order to determine which rules are applied, CSS calculates the specificity of each rule. The rule with the highest specificity is applied. The specificity of a selector is broken down into four levels: a,b,c,d.
If style is inline, a = 1 otherwise a = 0
b = total number of ID selectors
c = total number of class, pseudo-class and attribute selectors
d = total number of type selectors and pseudo-element selectors
Because the specificity is not calculated on base 10 here is a table to help translate them to base 10.