How does CSS determine when to apply one style over another?
I have been through the W3 CSS3 selectors document a few times, and that has helped me understand how to
I would suggest you get familiar with this for future reference. For this particular case, note point 3 under Cascading Order:
- Count the number of ID attributes in the selector.
- Count the number of CLASS attributes in the selector.
- Count the number of HTML tag names in the selector.
If these are applied to your code, .item a
has 1 class attribute + 1 HTML tag name, while .special
has only one class attribute. Hence, the former wins the right to style the special link.