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 trial

CSS The Selectors Solution

Why 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
Steven Parker
229,657 Points

A 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 :point_right: :link — :visited — :hover — :active.

Steven, here is today's daily reminder that you are indeed, THE MAN! 🏅🏆🥇

main 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
Steven Parker
229,657 Points

It should be blue when active. You can generally only see the active state while you are holding down the mouse button.