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 swit
I think you should at least consider the flow of User Interaction on links (or buttons).
Usually,
:link
has always been the default (untouched),:hover
comes into play.:active
comes in. That is the standard sequence of how we interact with links (or buttons). With the exception of :visited
, where the result is only obvious when the User has previously pressed the link.
It would be really helpful if you keep in mind the mnemonic: ' L o V e H A t e ' when dealing on links (except for :visited
, which doesn't work for buttons).
However, if you really want to do an override, say, you want to change the color of a link that was already visited on active state, you can do something like:
a:visited:active {
color: red;
}
But the bottom line is, avoid changing the standard sequence if it's not necessary.