Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS The Selectors Solution

Eddie Harmon
Eddie Harmon
Web Development Techdegree Student 17,093 Points

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
217,443 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.

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
217,443 Points

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