CSS Padding

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • padding: length|initial|inherit|unset;
  • padding-top: length|initial|inherit|unset;
  • padding-right: length|initial|inherit|unset;
  • padding-bottom: length|initial|inherit|unset;
  • padding-left: length|initial|inherit|unset;

Remarks

The padding property sets the padding space on all sides of an element. The padding area is the space between the content of the element and its border. Negative values are not allowed.

1: https://developer.mozilla.org/en/docs/Web/CSS/padding MDN

Also see this question, "Why does CSS not support negative padding?" and his answers.

Also please consider The Box Model when using padding. Depending on the box-sizing value, padding on an element can either add to the previously defined height/width of an element or not.

Related Properties:

margin

Padding on inline elements will only apply to the left and right of the element, and not the top and bottom, due to the inherent display properties of inline elements.



Got any CSS Question?