Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why “a:hover MUST come after a:link and a:visited(w3school)”? [duplicate]

I‘m study CSS in the "w3schools", in the chapter of "link", they say:

"When setting the style for several link states, there are some order rules:

a:hover MUST come after a:link and a:visited a:active MUST come after a:hover"

I want to know why the correct order is L.V.H.A, not L.H.V.A or another.

like image 896
Vayne Avatar asked Dec 12 '15 12:12

Vayne


People also ask

What is the difference between a hover and a visited?

Definition and Usage The :visited selector is used to select visited links. Tip: Use the :link selector to style links to unvisited pages, the :hover selector to style links when you mouse over them, and the :active selector to style links when you click on them.

When setting the style for several link states a link must come after a hover and a visited?

When setting the style for several link states, there are some order rules: a:hover MUST come after a:link and a:visited. a:active MUST come after a:hover.

What selector matches links that the mouse is hovering over?

The :hover selector is used to select elements when you mouse over them.


1 Answers

Pseudo-classes must be declared in a specific order.

The mnemonic LoVe HAte is always useful for remembering the correct order:

:link
:visited
:hover
:active

Each pseudo-class corresponds to an event which can only happen later in the timeline than the one before.

That is to say:

  1. A link is unvisited before it is visited.

  2. A link is visited before it is hovered over.

  3. A link is hovered over before it is in active use.

like image 154
Rounin - Glory to UKRAINE Avatar answered Nov 04 '22 08:11

Rounin - Glory to UKRAINE