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

Why does padding not attach to right side?

Why does this padding not cling to the right side on the right like it does on the left?

<html>
<head>
<style>
#footer {
   position: relative;
   padding: 100px;
   left: -20px;
   right: -20px;
   background-color: black;
}
</style>
</head>
<body>
<div id = footer>

</div>
</body>
</html>

3 Answers

<head>
<style>
#footer {
   padding: 100px;
   left: -20px;
   right: -20px;
   background-color: black;
}
</style>
</head>
<body>
<div id = "footer">

</div>
</body>
</html>

Try this code!

Thanks for your help but I have figured it out by placing an absolute div inside the relative div, then using that code :)

Antonio De Rose
Antonio De Rose
20,885 Points

did you want

padding-right : 100px;

No, I was wondering why

right: -20px;

does not make the padding attach to the right side like it does to the left

<div id = footer> is not right try <div id="footer">

That can't be the problem because it attached to the left side, so I know it selected it