Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEddie Harmon
17,094 PointsWhy doesn't the hover color work on a visited link? Does a visited link "override" the hover color?
So on this practice session, I know that both of my selectors are working (because the text-decoration is removed upon hovering). However, why does it not change the color to what is specified when hovering and then return back to the "visited" color designation? It remains the same forever after it has been visited, regardless of the hover state. Here is my CSS:
main a:hover { color: green; text-decoration: none; }
main a:visited { color: #b34e56; }
1 Answer
Steven Parker
231,275 PointsA pseudo-class will be overridden by any subsequent link-related pseudo-class. So to style links appropriately, put the :hover rule after the :link and :visited rules but before the :active one.
This is known as the LVHA-order :link — :visited — :hover — :active.
Eddie Harmon
17,094 PointsEddie Harmon
17,094 PointsSteven, here is today's daily reminder that you are indeed, THE MAN! 🏅🏆🥇
Agop Karoghlanian
Courses Plus Student 9,058 PointsAgop Karoghlanian
Courses Plus Student 9,058 Pointsmain a:visited { color: red; }
main a:hover { color: tomato; text-decoration: none; }
main a:active{ color: blue; }
This is the way i put my code. It's never blue. Before i hover, its always red. when i hover, it turns into tomato. But it never turns blue.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsIt should be blue when active. You can generally only see the active state while you are holding down the mouse button.