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


Padding property adds more space than wanted

I have a single line for my page footer, a <p> element wrapped inside of a <footer> element, like here:

  <p>this is my footer</p>

Inside my CSS, I am trying to get control of the padding, like so:

footer {
  padding: 1px;

The problem is that if I set the padding to anything but zero in this property, it adds what appears to be one whole em to the padding, something that I do not want. What is causing this, and how can I cleanly fix it?

1 Answer

Andrew McCormick
Andrew McCormick
17,730 Points

Is this the only style sheet being used? Also are using a browser reset at the top of your CSS?
Try using Firebug or DeveloperTools to see what's affecting your footer element.

I am using the updated normalize CSS at the beginning of my styles, instead of the old reset. I used Chrome's inspect element feature, but cannot seem to find out where exactly the extra padding is coming from. I did google this, and it seems to be a common problem. Why would a padding of 0 behave as expected, but a padding of 1 blow it up huge, like about 25px or so?

Update: When I inspect the element in DevTools, it shows the following styles being applied by the user agent stylesheet:

 p {
  display: block;
  -webkit-margin-before: 1em;
  -webkit-margin-after: 1em;
  -webkit-margin-start: 0px;
  -webkit-margin-end: 0px;

What I finally had to do was add the following rule to specifically target the paragraph within the footer container:

footer p {
    margin: 0;
    padding: 1px;

My question is this: why didn't the padding: 0 rule cascade down from the footer element into the child p element?