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 How to Make a Website Adding Pages to a Website Add a New Page

why do I remove the class selector from the portfolio anchor and move it to about...

what would this do to my css page when stating the class selected... wouldn't it change the about link the same as the portfolio link at that point?

3 Answers

David Diehr
David Diehr
16,457 Points

I see you posted this a while ago, and I imagine you've probably got an answer but just in case. The reason you move the class selector from one line to the other is to move where the css styling is being applied. When your browser is reading the index page, it will apply that css to where the selector is at on that page (the index link) and when you're on the about page it will apply it to where you have it on that page (the about link). You just gotta remember these are different pages, so the links on them are different (even though we think of the header of the website as not changing, it's actually two different headers on two different pages connected by link) changing one on one page won't change it on the other. It's when you change the css that's applied to multiple pages that you change two pages at once. But in this case, you are only changing the html.

hello ,

you can remove it manually on each page for example

here in index.html

<nav>
        <ul>
          <li><a href="index.html" class="selected">Portfolio</a></li>
          <li><a href="about.html">About</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </nav>

here in about.html

<nav>
        <ul>
          <li><a href="index.html">Portfolio</a></li>
          <li><a href="about.html" class="selected">About</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </nav>

here in contact.html

<nav>
        <ul>
          <li><a href="index.html">Portfolio</a></li>
          <li><a href="about.html">About</a></li>
          <li><a href="contact.html" class="selected">Contact</a></li>
        </ul>
      </nav>

Or you can try create a function through javascript ,

Best regards

that wasn't my question..