Why does the ID selector override the class selector even if the class is declared later?
Because ID selectors have higher specificity than class selectors, the browser applies the ID style regardless of order. Specificity beats source order.
💡 Higher specificity selectors always win over lower ones, no matter where they appear.
Why doesn't the inline style get overridden by the ID selector?
Inline styles have the highest specificity (except !important), so they override ID selectors unless !important is used.
💡 Inline styles trump all selectors except !important rules.
What happens if two selectors have the same specificity?
The browser applies the style declared last in the CSS source, so later rules override earlier ones if specificity ties.
💡 When specificity ties, the last declared style wins.