Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Layout Basics Page Layout with the Float Property The Float Challenge Solution

Dimitris Karatsoulas
Dimitris Karatsoulas
5,787 Points

Difference between nav and div elements.

So, we had to apply a certain width on . primary and .secondary so that float could work for them and have the desired two-column layout. On the contrary, we didn't have to apply any width on .main-nav li elements when we were setting up the navigation layout, float: left worked just fine. Why is that?

My best guess is if you just use <nav> and decide to update it with a log in button nested beside the nav it would probably push the nav property to the left of right and break your nav bar down. with a width of 100%. why you use containers to help hold certain elements inside that container that you want there. so you can add a login button or a input button to comfirm a email or something along those lines.

1 Answer

Dimitris Karatsoulas
Dimitris Karatsoulas
5,787 Points

Actually what I meant is that I don't understand the difference in the behaviour of those elements. The divs .primary and .secondary need a width so that they can be displayed side by side, using float on them. Although we also use float on the li elements of nav but we don't have a width they are still displayed side by side.