The title basically says it all.
Suppose I have an element which I want to change color on :hover
, but while clicked, I want it to switch back to its original color. So, I've tried this:
a:link, a:visited, a:active {
background: red;
}
a:hover {
background: green;
}
As it turns out, this doesn't work. After a lot of head-scratching, I realized that the :hover
state was overriding the :active
state. This was easily solved by this:
a:link, a:visited {
background: green;
}
a:hover {
background: red;
}
a:active {
background: green;
}
(I could combine the 1st rule with the 3rd one).
Here's the fiddle: http://jsfiddle.net/V5FUy/
My question: is this the expected behavior? As far as I understand this, the :active
state should always override the :hover
state, since the :active
state will almost always be accompanied with the :hover
state.
:active
and:hover
were added (to CSS1 and CSS2, respectively)... We are seemingly in history territory at this point, and not programming. – Goodsizeda
tag in a style sheet is - LoVe before HAte.Link
->Visited
->Hover
->Active
– Tabor