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

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!