Web Lab Documentation

Padding

Category:CSS Properties

Padding

The Padding property specifies how much space should appear between the content of an element and its border. It is a shorthand for padding-top, padding-right, padding-bottom, and padding-left.

Examples

Single Padding Value

Using the shorthand property to set the padding for all four sides of a <p> element to 40 pixels.

p {
  padding: 40px;
}

Multiple Padding Values

Setting multiple padding values for the four sides of a <p>element.

  • The top padding is 10px.
  • The right padding is 5px.
  • The bottom padding is 15px.
  • The left padding is 20px.
p {
  padding: 10px 5px 15px 20px;
}

Syntax

padding: value;

Tips

  • The default padding value is 0.
  • When one value is specified, it applies the same padding to all four sides.
  • You can specify the paddings for the individual sides of an element using the CSS padding-top, padding-right, padding-bottom, and the padding-left properties, respectively.

Additional Information

Found a bug in the documentation? Let us know at support@code.org.