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

HTML How to Make a Website Customizing Colors and Fonts Use Color in CSS

Anwar Rizalman
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Anwar Rizalman
Python Development Techdegree Graduate 33,620 Points

Do we really need to change the color for nav a:visited ?

I ask this because I tried just with 'nav a' without the 'nav a: visited' , the color of the link after visiting it stays the same as the the color before visiting it. What I mean is, I declared the color for nav a (and this also applies to h1 h2) to #fff and the the color is white and also stays white even I visited the link (without having to apply the nav a: visited. THankyou. **Sorry for the broken english.

György Varga
György Varga
19,198 Points

When you just use 'nav a' you set the default color of the anchor element, so if you hover over or visit a link you will get the same color. You should set a different color for 'nav a:visited' because that color will indicate that you have visited the site already.

Stamos Bolovinos
Stamos Bolovinos
4,320 Points

I agree to what Anwar asked and also to György's comment.

nav a, nav a:visited{
  color: #fff;
}

has exactly the same effect as

nav a {
  color: #fff;
}

But the question here is still not answered: the teacher wanted to have the unvisited AND visited link in the same color. So why did he use the above code. It's a programming principle to use less code if possible.

1 Answer

Stamos Bolovinos
Stamos Bolovinos
4,320 Points

I think the answer to this is, the teacher wanted to hardcode visited nav links to be white, as he might want to add more links later on that are not in the nav section. Probably he want's these links to behave differently. He might add then for example

a:visited{
  color: blue;
}

and to make sure the nav links are not affected, he has added it already to the nav section.