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

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