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

Matt Jones
Matt Jones
1,950 Points

Issue with NAV not changing color. CSS

Currently working on the website project and I'm having an issue. The three links on the nav "portfolio" "about" and "contact" are all white apart from the current page, but when I move to another page, the original "portfolio" stays green and doesn't turn white.

/* nav link */
nav a, nav a:visited {
  color: #fff;
}

/* selected nav link */
nav a.selected, nav a:hover {
  color: #32673f;
}

nav {
color: #fff;
}
Abhijit Das
Abhijit Das
5,022 Points

could you please post your html, so can check it properly, i guess you have to cascade nav style properly, try to keep nav link after selected nav link .

Joshua Morgan
Joshua Morgan
7,077 Points

I second Abhijit Das - we need your html file to tell you what the issue is. The issue could be in the html, but we also need to run it ourselves in order to troubleshoot.

Joshua Morgan
Joshua Morgan
7,077 Points

Update:

I built a basic site with a nav ul as you described and applied the styles from above. I did not experience the issue you described. The links turned green on hover and clicks, and defaulted to white on all pages. I used Chrome to test it, so make sure it isn't a browser issue, though i don't think something like this would be.

One thing I did notice is your a.selected is selecting an anchor with the class .selected, so if you haven't declared that class in your html or css, I don't think that is going to successfully call your color style.

It looks like someone else has asked a similar question, so you may take a look at this and see if it applies to your situation:

https://teamtreehouse.com/community/nav-aselected-is-not-working-can-someone-take-a-look-at-my-code-and-see-what-im-doing-wrong

1 Answer

The people before me are correct. You may also want to copy all of your CSS and put it into CSSlint.net.

That will show you all of your CSS errors.