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!

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

Jamie Reardon
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Question about the padding on the cleared footer element?

Hi all, so I've been following along with this course and making my own project in the background, I decided to have the same layout as this static one page that Nick designed. Only however, I decided for my own project to have a background on the footer element instead of a transparent one like Nick has by blending it in with the body's white background.

So, while trying to have a separate background color on the footer element, I stumbled across a problem I couldn't figure out, which was that, I can't use a margin value to separate the footer from the gallery ul (content above the footer), it seems like margin properties don't affect any cleared elements, I have tried this with other elements that use the clear: property.

Why is that? So my intended question is, how do I go about having my own background color on the footer without the use of the padding-top property that Nick used to resolve his space in the transparent background at 02:26? I didn't get to see an alternative/explanation to this on the course. Thanks!

<div id="wrapper">
        <ul id="gallery">
            <a href="img/numbers-01.jpg">
              <img src="img/numbers-01.jpg" alt="">
              <p>Experimentation with color and texture.</p>
            <a href="img/numbers-02.jpg">
              <img src="img/numbers-02.jpg" alt="">
              <p>Playing with blending modes in Photoshop.</p>
            <a href="img/numbers-06.jpg">
              <img src="img/numbers-06.jpg" alt="">
              <p>Trying to create an 80's style of glows.</p>
            <a href="img/numbers-09.jpg">
              <img src="img/numbers-09.jpg" alt="">
              <p>Drips created using Photoshop brushes.</p>
            <a href="img/numbers-12.jpg">
              <img src="img/numbers-12.jpg" alt="">
              <p>Creating shapes using repetition.</p>

      <a href="http://twitter.com/nickrp"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a>
      <a href="http://facebook.com/nickpettit"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a>
      <p>&copy; 2014 Nick Pettit.</p>

#gallery {
  margin: 0;
  padding: 0;
  list-style: none;

#gallery li {
  float: left;
  width: 45%;
  margin: 2.5%;
  background-color: #f5f5f5;
  color: #bdc3c7;


footer {
  font-size: 0.75em;
  text-align: center;
  clear: both;
  padding-top: 50px;
  color: #ccc;

1 Answer

Alan Brown
Alan Brown
20,524 Points


gallery:after {

content: ""; display: table; clear: both; }

Google clearfix if you'd like to understand why ;-)