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 trialjames li
Courses Plus Student 460 PointsSize 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
Jason Anello
Courses Plus Student 94,610 PointsHi 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
17,878 PointsIf 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
6,595 PointsWhat is under footer: { }? Put your code here.
Marcelo Retana
2,534 PointsPaste your code please.
james li
Courses Plus Student 460 PointsHere'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>
Paul Barron
6,595 Pointsneed code
james li
Courses Plus Student 460 Pointsfooter { font-size: 0.75em text-align: center; padding-top: 50px; color: #ccc; background: red; }
Paul Barron
6,595 Pointscode is what's in the css doc
james li
Courses Plus Student 460 Pointsthanks guys. and Jason, your answer is perfect. I tried removing the float, and the footer went back to its original size. thx:-)
Jason Anello
Courses Plus Student 94,610 PointsGlad it helped.
Jason Anello
Courses Plus Student 94,610 PointsOh, and if you need to post code in the future this should help: https://teamtreehouse.com/forum/posting-code-to-the-forum