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.

HTML How to Make a Website Styling Web Pages and Navigation Style the Image Captions

Caroline Guzman
Caroline Guzman
433 Points

Wondering about floating footer

Nick says that when the footer ends up floating with the gallery it is acting the way it has been told to. He tells us we can fix it by adding 'clear: both;', however, I want to know what it is about the footer style code that tells it to float with the gallery if in actuality there is no 'float' code in the footer element. This is a snapshot of my css without fixing the footer. https://w.trhou.se/zgyxlvb5dv

1 Answer

Erik Nuber
Erik Nuber
20,629 Points

It isn't that the footer is floating, it is that the items above it are set to float.

When something gets "floated" it is taken out of the normal layout and the item loses its height so things that around it behave in such a way to run around that item.

When you clear the float, it just tells the specific item, in this case the footer to respect the height of the floated items so it pushes it back down to where it belongs

Here is an excellent description about floats and clears that should help you understand better.

https://css-tricks.com/all-about-floats/

Caroline Guzman
Caroline Guzman
433 Points

Makes so much sense. Thank you!