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 Style the Image Captions

George Kadar
George Kadar
2,721 Points

Clearing the Footer

I don't quite understand why the footer is affected by the 'float' and needs to be 'cleared' in the css file? The way I'm understanding it, is that the 'float' property is inside the ID gallery, which is the ID of the unordered list of images, but the footer is outside the unordered list in the html file? Hope this makes sense. No a huge deal, really. I'd just like to know.

2 Answers

Dennis de Vries
Dennis de Vries
9,440 Points

Hi George,

The 'clear' property reacts to the preceding elements only. So in this case, clearing the ID gallery would only make it react to whatever floating elements are above that in the html. When using a float, the natural behavior of following elements would be to fill up the remaining space. So in this case, the ID gallery might float left so the next element, the footer, jumps in the open space on the right. By telling the footer to stay 'clear' of this 'float' in the preceding element, it won't jump to the right, but instead stay below.

If you want to know more, check out MDN about the clear property: https://developer.mozilla.org/en-US/docs/Web/CSS/clear

Hope this helps Dennis

Mark Shiel
Mark Shiel
12,225 Points

So what you are saying in essence is once a float is declared no matter what ID it is inside, everything will float according to that rule until something is defined differently?