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 trialAdriana Karlak
1,450 PointsThe color I set for the visited links is being applied to the links before they've been visited. Why?
This is what my CSS code looks like:
/* Create visited and hover styles for all links inside 'main' */
main a:hover { background-color: skyblue; }
main a:visited { color: red; }
The 'a:hover' declaration works just fine. When I hover over the links, the background color changes, as it should.
But the 'a:visited' selector isn't working right. The links are red before I've even clicked them as while as after. They should only be red AFTER, not before.
In an effort to fix this, I experimented by making the property and value for the 'a:visited' selector different. I set the background-color to orange. What that did was even stranger. It made the background color of those links change to orange only when I hovered over them! Which is strange, because the selector I was style is not a ":hover" selector, it's a ":visited" selector.
Can anyone tell me what I'm doing wrong? Or if it's supposed to be doing this? Because I don't think it is. This is the first problem I've had with this course so far.
2 Answers
qdzfplofsk
22,025 PointsIn my experience that is because the browser thinks you have visited the link. Try a new browser window with cleared history to reset.
Agop Karoghlanian
Courses Plus Student 9,058 PointsI have the same issue.
Adriana Karlak
1,450 PointsAdriana Karlak
1,450 PointsI thought of this too. I also thought maybe I HAD opened the links and I just forgot. So I experimented and added an entirely new link to the HTML (making sure it was in the main tags) to see if the CSS would style it how it was supposed to. It still did the same thing though when I opened and refreshed the page. So that is not the issue.