Problem Statement
Which CSS pseudo-class is used to style a link that has been visited?
Explanation
The colon visited pseudo-class is used to style links that the user has already visited. Browsers keep track of visited links and apply different styles to them, typically displaying them in a purple color by default. CSS provides four pseudo-classes for link states. Colon link targets unvisited links. Colon visited targets visited links. Colon hover targets links when the mouse pointer is over them. Colon active targets links at the moment they are being clicked. The order of these pseudo-classes in your CSS matters. The recommended order is link, visited, hover, active, which can be remembered as LVHA or love hate. This order ensures that hover and active states work correctly on both visited and unvisited links.
Code Solution
SolutionRead Only
/* Link pseudo-classes in correct order */
/* Unvisited links */
a:link {
color: blue;
text-decoration: none;
}
/* Visited links */
a:visited {
color: purple;
}
/* Mouse over link */
a:hover {
color: red;
text-decoration: underline;
}
/* Active/clicked link */
a:active {
color: orange;
}