-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
  • 1,887
  • 7
  • 29
  • 43
Jeyanth
  • 443
  • 1
  • 6
  • 17

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
  • 857,932
  • 118
  • 1,152
  • 1,264