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 trialGraham Stoker
2,566 PointsBackground Padding 6:47
At 6:47 into the video the instructor says that the background property is for top padding, would it not be padding for left and right ?
1 Answer
Sidney François
2,092 PointsI am assuming you referring to the 0
and 2px
properties of the background.
background: url(image.jpg) no-repeat 0 2px;
You shouldn't call those values padding
, because while they technically do something similar, it is really the background-position
you are changing.
But you are right: If you were to define margin: x y;
or padding: x y
, the x would be the vertical position, and y the horizontal position.
// Creates margin of 200px LEFT and RIGHT
margin: 0 200px;
//Creates padding of 100px TOP and BOTTOM
padding: 200px 0;
The background-position on the other hand works differently.
// Pushes background image 200px from top
background: url(image.jpg) no-repeat 0 200px;
Graham Stoker
2,566 PointsGraham Stoker
2,566 PointsThat was a fast reply and great explanation thanks :) it makes sense now, i know you did say that it would be covered later also.