CSS Padding Property

How to use the CSS padding to control elements on a page.

The CSS padding property is the short-hand way of specifying padding.

Padding is used to create a space between an elements content, and its borders. But it is also used as "margin", places where margin is problematic to use. Padding can look exactly like margin, when used on elements without a background.

Possible Values

Note: Negative values is not allowed for padding.

Using CSS padding

This example, sets the padding in the following format: Top Right Bottom Left

p {
  padding: 2em 1em 3em 4em;
}

The above is the equivalent of:

p {
  padding-top: 2em;
  padding-right: 1em;
  padding-bottom: 3em;
  padding-left: 4em;
}

Inherited? NO!

Post comment

Links that you insert are not nofollowed, but will be removed by admins if they are considered spam.

[url=Absolute URL for page]TITLE[/url]

You should insert code boxes around code examples, which will be automatically syntax highlighted.

[code1 html|css|javascript|php|sql]Your Code Here[/code1]

You may want to read our Privacy Policy before submitting your comment.