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
Elizabeth Mawer
9,554 PointsClass 'selected' is not working on my website?
<nav> <ul> <li><a href="index.html" class="selected"><button type="button">Homepage</button></a></li> <li><a href="Animal Portraits"><button type="button">Animals</button></a></li> <li><a href="People Portraits"><button type="button">People</button></a></li> <li><a href="Buildings"><button type="button">Buildings</button></a></li> </ul> </nav>
Before I added buttons to my webpage the class="selected" was working. Since adding the buttons it no-longer works, can anyone help please?
2 Answers
Vasyl Kozhushko
6,405 Pointsas I know, if you remove "button" tags it should become to work. try
<code>
<ul>
<li><a href="index.html" class="selected">Homepage</a></li>
<li><a href="Animal Portraits">Animals</a></li>
<li><a href="People Portraits">People</a></li>
<li><a href="Buildings">Buildings</a></li>
</ul>
</nav>
</code>
Olga Kireeva
9,609 PointsIt's not a good practice to put a button inside an anchor tag. The button tag defines a clickable button, and an anchor tag is also a clickable tag. The class "selected" probably doesn't work because of these inconsistencies. You can style an anchor tag with CSS making it look like a button. If you intend to use buttons you will need to write a code for them in JavaScript.