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

james li
PLUS
james li
Courses Plus Student 460 Points

Size of Footer

Hi, before I do the "clear both" to push the footer element to the bottom, I changed the background color of the footer to red just to see the size of the element. To my surprise it was huge, almost the size of the entire wrapper (which contains section & footer). I don't understand why is the footer element so huge??? All it has in it are 2 icons, twitter and facebook, and a copyright symbol. Also what determines the size of a certain element (img, h1, p,..etc) in HTML?

9 Answers

Hi James,

The red background is actually going to extend all the way to the top of the header but you don't see it because the header is on top in the layering order.

The reason for this is because the previous elements are floated and so the content box for the footer will extend all the way to the top.

Before you clear the footer, try giving it a top margin of say 30px to test this out. You will see that this produces a 30px gap above the header.

By clearing the floats in the footer, you're saying that the footer element must drop below all previously floated elements. This forces the content box to drop below the gallery items and then the footer takes on it's natural height that it should be and the size of the red background that you have will seem reasonable.

This same problem happens between the floated header and the wrapper div that follows. You should add a clear: both to your wrapper div as well so that it's content box will drop below the floated header.

What determines the size of an element in general is it's content, assuming you have not forced an element to be a certain width or height.

Generally height will be based on how tall the content is. Width depends on whether it's a block level or inline element. An inline element is only as wide as it needs to be to contain the content. Whereas a block level element will take up the full width of it's parent even if it's content doesn't require it.

Let me know if anything needs to be clarified.

Jennifer Crawshaw
Jennifer Crawshaw
17,878 Points

If you have not added any layout styling, your HTML element will just take up blocks across the screen. But post your code to see if maybe you've included inside of a <div> that you didn't mean to.

Paul Barron
Paul Barron
6,595 Points

What is under footer: { }? Put your code here.

Paste your code please.

james li
PLUS
james li
Courses Plus Student 460 Points

Here's what's inside the footer

<footer> <a href="https://twitter.com/Bayfairfoods">
<img src="img/twitter-wrap.png" alt="Twitter Logo"> </a> <a href="https://www.facebook.com/rex.iacobus?ref=tn_tnmn"> <img src="img/facebook-wrap.png" alt="Facebook Logo"> </a> <p>Ā© 2014 James Li.</p> </footer>

james li
PLUS
james li
Courses Plus Student 460 Points

footer { font-size: 0.75em text-align: center; padding-top: 50px; color: #ccc; background: red; }

Paul Barron
Paul Barron
6,595 Points

code is what's in the css doc

james li
PLUS
james li
Courses Plus Student 460 Points

thanks guys. and Jason, your answer is perfect. I tried removing the float, and the footer went back to its original size. thx:-)

Glad it helped.

Oh, and if you need to post code in the future this should help: https://teamtreehouse.com/forum/posting-code-to-the-forum