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

John Levy
John Levy
1,451 Points

How to highlight a box when I click on the page

My goal is to have three pages and what ever page the user is oin the box around the text is highlighted in blue. Shown in the code one page willb e for beginner, one for advanced and one for bundle so whatever page they will be on there will be a ble box surrounded the text. I am having trouble figureing how to do this. Bellow is the HTML5 and CSS code I have used for this. Thanks in advance. HTML5- <ul class="options"> <li><a href="#">BEGINNER</a></li> <li><a href="#">ADVANCED</a></li> <li><a href="#">BUNDLE</a></li> </ul>

<div id="rectangle"> </div>

 <div id="rectangle2">
 </div>

 <div id="rectangle3">
</div>

CSS

rectangle {

 border: 5px 15px grey solid;
 background-color: #847bf7;
 height: 50px;
 width: 250px;
 position: absolute;
 top: 150px;
 left: 200px;

} #rectangle2 {
border: 5px black; background-color: black; height: 50px; width: 250px; position: absolute; top: 150px; left: 700px;*/ }

#rectangle3 { border: 5px black; background-color: #847bf7; height: 102px; width: 430px; position: absolute; top: 253px; left: 5px;

2 Answers

Erik Nuber
Erik Nuber
20,629 Points

You are likely going to need a class called "selected" and add it into your navigation.

For example

            <nav>
                <ul>
                    <li><a href="index.html" >Home</a></li>
                    <li><a href="miscWork.html">Miscellaneous Work</a></li>
                    <li><a href="about.html" class="selected">About</a></li>
                    <li><a href="contact.html">Contact</a></li>
                </ul>
            </nav>

in this case the about.html page has a selected class on that nav item and you can style it as you want.

John Levy
John Levy
1,451 Points

Thanks for your help, that worked