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.
Why do all links on a page change colors when i just click on specific link?
I have setup a:link, and a:visited correctly, and the colors correspond correctly. However, whenever I click on a link that was in an unvisited state, it causes ALL of the other links (that have not been clicked) to change into the a:visited state..
It should only change the one specific link that I clicked into a 'visited' state. is there any way to define this?
Ah I see. I had this problem too. At some point it looks like Guil went through and gave all the hrefs different links like #more, #wildlife, etc so this wouldn't happen but didn't tell us. I'm following along in my own text editor instead of using workspaces so I didn't get that update.
Jay Dacosta3,425 Points
All the links change back to blue after clicking because you have all the links set to the same target ( href="#" ). You should notice that all the links except the "Back to top>>" one at the bottom have changed. That's because we gave that bottom link a specific target.
Essentially, the browser thinks you have already visited all those links with the target of "#". if you change the href/url/file-path you'll notice that those items will change back to orange until you click them again. Hope that helped
What type of selector are you using? Can you post a snippet of the code? If you haven't already, try giving the link you would like to target a class and then use that class name in your CSS as the selector. That is one of a number of ways you may be able to fix your problem. Hope this helps!