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


Robbie Singh
Robbie Singh
3,675 Points

How can I ensure that my nav li items are centered on the page?

nav { background: #4b0082; }

nav ul { list-style: none; margin: 0px 0px 50px 0px; padding: 0px; }

nav li { display: inline-block; }

nav a { font-weight: 900; padding: 30px 20px; }

2 Answers

Hi Robbie,

There are many ways to go about this - one way is to center the ul element with a text-align: center. Here's a Codepen using your code. I just centered the ul and made li text white.

Robbie Singh
Robbie Singh
3,675 Points

Thanks Robert! That worked perfectly.