https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
You can think of the specificity of a rule as similar to a multi-part number (A.B.C.D).
A. sum of identity selectors
B. sum of class selectors
C. sum of type selectors
D. order of rule matching the given weight
!important will override a prior directive, later !important likewise. it should be used only as a last resort, and you should re-think your structure if you ever need it.