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 Styling Web Pages and Navigation Build Navigation with Unordered Lists

Bert Coppens
Bert Coppens
5,609 Points

why do we use for the footer clear both and for the header width 100%?

For the footer we made sure that it came clearly under the section by using "clear: both;" in our css file. Why donΒ΄t we apply "clear: both;" also for the heasder so it stays above the rest instead of saying "width: 100%", is there a real difference?

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Bert,

The clear property is designed for elements that proceed other elements therefore it wouldn't work on the header since it's the first element in our page layout which is the reasoning behind using 100% instead as that will ensure the header remains at the width of it's parent container no matter what.

In the case of the footer we use clear to ensure it doesn't wrap unexpectedly if an element preceding it has an float property assigned to it.

Hope that helps.

Bert Coppens
Bert Coppens
5,609 Points

Hi Chris,

Thanks for explaining!