-1

I'm learning CSS. I'm getting confused when I faced up the order ':hover must come after :link and :visited'.

Practically, in order to visit a link, we have to click it first and in order to click the link, we need to hover it. If so, why such constraints in order..?? Kindly help.

jasie
  • 2,192
  • 10
  • 39
  • 54
Jeyanth
  • 531
  • 2
  • 6
  • 19

1 Answers1

5

Given CSS selectors that are equally specific, rules are applied in order.

If an anchor is both a link and hovered, then both rules will apply.

a:hover { color: blue; }
a:link { color: red; }

It is hovered so it is blue, but it is a link, so the blue is overwritten with red.

That makes the hover rule more-or-less pointless.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335