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 CSS Foundations Selectors Link and User Action Pseudo-Classes

Zach Saul
Zach Saul
11,156 Points

Visited links changing colors without creating a "visited" pseudo class?

not sure I completely understand why it is that when (at around 2:30 in this video) you select anchor elements with the psudo-class link

a: link { color: red; }

that the result is the browser restoring it's default styles (the purple) after the user has clicked on it.

is it the case that the browser default already has some sort of mechanism for determining whether a link has been clicked or not? because from my assessment (using only the code in these project files) we have not given the browser any instructions on how to differentiate between visited and non-visited pages.

hope you guys can clarify,

3 Answers

Every browser has this user agent CSS. When you visit a link it will make it automaticaly purple. The :link selector is used to select unvisited links.

Zach Saul
Zach Saul
11,156 Points

so essentially what you're saying is the browser and/or CSS already understands how to differentiate between visited and unvisited links without me as a coder having to do anything, right?

Yes. but if you want to overwrite you can use this a:visited{color:red;}

Zach Saul
Zach Saul
11,156 Points

Ok thanks George! I realize now that i was over analyzing pseudo class functionality and its a lot more straight forward than I might have thought

Zach Saul
Zach Saul
11,156 Points

so essentially what you're saying is the browser and/or CSS already understands how to differentiate between visited and unvisited links without me as a coder having to do anything, right?