Need CSS text color for: hover over: visited
I have a css code that shows the background color on hover. White text on blue background.
Otherwise, if there is no hover, the text will be blue with a white background. However, when the link has been visited, the text remains blue with a blue background on hover.
How can I make the color of the hover text take precedence?
a:link{
color:#3399cc;
}
a:hover{
background-color:#3399cc;
color:#ffffff;
}
a:visited{
color:#3399cc;
}
a:active{
color:#3399cc;
}
source to share
See Eric Meyer's article on the topic: Ordering Link States
This assumes you are using the LVHA rule which refers to the order of the pseudo-classes among the CSS rules. Some easily recognizable abbreviations appear in the comments when ordering (adding :focus
to the package):
- L ord V ader F ormer H andle, A nakin
- L ord V ader F roze H ans A ss li>
One method is to use the keyword !important
:
a:visited
{
color:#3399cc;
}
a:hover
{
background-color: #3399cc;
color: #ffffff !important;
}
This ensures that it :hover
takes precedence.
Might also work to replace yours a:visited hover
, which means element <hover>
(doesn't exist!), With a:visited:hover
.
As mentioned, changing the order of the styles should be a sufficient fix: later definitions take precedence over earlier ones.
source to share