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!
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
Tabrez Ahmad
1,822 PointsListed Items
I've just started with Treehouse and one of the first exercises was adding an unordered list item to the menu. This was the following code I wrote:
<ul class="nav">
<li><a href="#"> About </a></li>
<li><a href="#"> Cupcakes & Prices </a></li>
<li><a href="#"> Locations </a></li>
<li class="last"><a href="#"> Contact Us</a></li>
</ul>
Everything is completely clear to me, except for one part. In line 5, <li class="last">, must you always specify the last item in a list? If yes, why does this need to be a class?
Thanks in advance! :)
1 Answer

Andrew Shook
31,709 PointsYou do not need to specify the last item in a unordered list. You simply need to :
<ul>
<li>about</li>
<li>cupcakes & prices</li>
<li>locations</li>
<li>contact us</li>
</ul>
Hope this helps.
Tabrez Ahmad
1,822 PointsTabrez Ahmad
1,822 PointsThanks for the reply Andrew.
I just realised I never formatted my code correctly there. I've inserted it now according to how the tutorial instructed.
So, I get what you're saying, but I don't understand why the video instructs the user (pupil?) to enter:
<li class="last">
I understand the nav class though.
Any ideas?
Thanks!
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsOh, well its been awhile since I took that course, but my guess is that if you look in the CSS file you will see that anything with class of last doesn't have a right margin. This helps to prevent the last item in a list from being pushed down a row vertically.
Tabrez Ahmad
1,822 PointsTabrez Ahmad
1,822 PointsAh! That makes sense. Thanks for that. I'm still part-way through this first stage so I'm sure he'll explain in detail later.