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


Cheryl Oliver
Cheryl Oliver
21,676 Points

Nav bar is not displaying inline

I need to display the nav bar links all next to each other and in the center of the viewport. I cant seem to figure out why it wont. Please take a look at my code and let me know what Im doing wrong:


<div class="main-nav"> <h2 class="name" id="top">Cheryl Casteling</h2> <ul class="nav"> <li><a href="index.html">HOME</a></li> <li><a href="#portfolio">PORTFOLIO</a></li> <li><a href="#contact">CONTACT</a></li> </ul> </div>


.main-nav li a { color: black; background-color: #fafafa; padding: 5px 5px; display: block; text-decoration: none; margin: 2px 0 0 0; }

.main-nav, .main-content, .contact, .profile-image, .intro { text-align: center; }

/* ///// MEDIA QUERIES ////// */

@media (min-width: 768px) { .main-nav li a { display: inline-block; text-align: center; vertical-align: top;


.nav {
    display: inline-block;
    text-align: center;


1 Answer

Tomas Pavlik
Tomas Pavlik
26,726 Points

Hi Cheryl, try to target nav li and add display: inline - this should work...