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

HTML How to Make a Website Styling Web Pages and Navigation Build Navigation with Unordered Lists

Alex Hird
Alex Hird
2,767 Points

why do i have to input display: inline-block; in nav li and not nav ul.

why do i have to input display: inline-block; in nav li and not nav ul. nav ul contains the list-style:none declaration so why can't it have the display: inline-block declaration. thanks

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

It could, but it's not really needed. An unordered list has a default display of block. A list item doesn't. So you have to tell the list items specifically to display the way that you want. Here's some information from the W3C.

https://www.w3.org/TR/html-markup/ul.html

https://www.w3.org/TR/html-markup/li.html

Steve Brewer
Steve Brewer
15,030 Points

Because you want the items in the list, the <li>'s to display inline and as blocks alongside the other items.

Putting it in the ul would make all ul elements display as inline blocks.