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

CSS How to Make a Website Responsive Web Design and Testing Adjust the Profile Page and Header

Xenon Thong
Xenon Thong
2,311 Points

Display issue with <header> and <nav>

In the main.css, if I do not include "float: left" for the header element, and I use "float: right" for my nav element.

Why is my nav element being displayed outside of the header element (when the page loads), even though the nav tag is being nested within the header tag in my html mark up?

1 Answer

Hi Xenon,

if you remove the float:left; property from the parent element (header) , you'll need to give him position:absolute, because both of his children are being floated, the parent needs to be too in order to keep his height.

Float property takes the element out from the normal flow.

So either you keep the float: left; to your header, or give it a position: absolute; property. Or you can eventually specify height in px for your header, but that is not a nice way to do it.

Xenon Thong
Xenon Thong
2,311 Points

Hi Milan,

thanks for the help and explanation.