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 trialBert Coppens
5,609 Pointswhy 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
26,676 PointsHi 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
5,609 PointsBert Coppens
5,609 PointsHi Chris,
Thanks for explaining!
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsYou're welcome.