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.

CSS

Tobi Ogunnaike
Tobi Ogunnaike
2,242 Points

Basic CSS not working.. need help to fix code

/*************************** NAV ***************************/

/Nav background on mobile/ nav{ text-align:center; padding:10px 0; margin: 20px 0 0 ; }

nav ul{ list-style:none; margin:0 10px; padding:0; }

nav li{ display:inline-block; }

/Nav link/ nav.a, nav a:visited} color:#fff; }

/*Selected nav link */ nav a.selected,nav a:hover{ color:#000; }

The last 2 bits of code are not working- the nav.a and nav a:visited, and the nav a.selected, nav a:hover.

Can you help me figure out why?

Thanks

2 Answers

Navid Mirzaie Milani
Navid Mirzaie Milani
6,273 Points

it isn't nav.a it is nav a first of all like nav a:hover and nav a:selected ;)

thus.

nav a {
   color:red;
   etc.
}

nav a:hover {
   color:orange;
}

nav a:selected {
  color:purple;
}

if you say nav.a then the html looks like

<a href="foo.html"  class="a">bla</a>
Tobi Ogunnaike
Tobi Ogunnaike
2,242 Points

Thanks! Just changed it and it works.

Not sure what you're trying to explain the second bit of code?

As Navid Mirzaie Milani mentioned:

<a href="foo.html"  class="a">bla</a>

This will refer to a class called 'a'. CSS Selectors are easy to mix up. I do it all the time :)

Tobi Ogunnaike
Tobi Ogunnaike
2,242 Points

Haha thanks.

Not sure what you mean by this bit of code you posted though. What is that?