|
Search This Site
|
Margin & Padding in CSS
The PadingIf you recall, the padding surrounded the content. The padding gives some space around this area based on your specifications. It is the diatance between the border and the content itself. The values of padding can be specified in pixels or even as a percentage.
style.css
body
{
padding: 20px; <----- padding set to 20 pixels
}
style.css
body
{
padding-top: 20px; <----- Sets the top padding
padding-right: 30px; <----- Sets the right padding
padding-bottom: 25px; <----- Sets the bottom padding
padding-left: 30px; <----- Sets the left padding
}
style.css
body
{
padding: 20px 30px 25px 30px; <----- Sets the top, right, bottom and left paddings
respectively
}
The MarginIn the box model, the margin was outside the border. It clears this area based on your specifiation. Just like the padding, the values that can be specified in pixels or even as a percentage.
style.css
body
{
margin: 10px; <----- margin set to 10 pixels
}
style.css
body
{
margin-top: 10px;
margin-right: 20px;
margin-bottom: 15px;
margin-left: 20px;
}
style.css
body
{
margin: 10px 20px 15px 20px;
}
Previous Lesson - The Box Model
Next Lesson - Floating
|
|
© Copyright 2010 | All Rights Reserved
|