The padding property is a shorthand that sets the inner spacing on all four sides of an element — between the content and the border. It sets padding-top, padding-right, padding-bottom, and padding-left.
Use one to four values (length or percentage). Negative values are invalid. It is not inherited. Initial value for each side is 0. The element’s background paints through the padding area.
Baseline · Widely available.
Not deprecated and not experimental. Core box-model spacing supported in all browsers for decades.
Padding vs margin.
padding is inside the border. margin is outside the border, between this element and its neighbors.
Left.12px is the fourth value. Remember: clockwise from the top.
Edge Cases & Pitfalls
If the box looks bigger than expected, one of these is usually why.
negative
Negative padding is invalid
Unlike margin, padding cannot be negative. The declaration is ignored if you try.
percent
Percentages use the containing block width
Even top and bottom percentage padding resolve against the containing block’s inline size (usually width), not its height.
box-sizing
Default width does not include padding
With content-box, padding adds to the total size. Use box-sizing: border-box so width includes padding and border.
auto
auto is not valid for padding
Centering with auto is a margin trick. Padding has no auto keyword.
table
Some table parts ignore padding
Padding does not apply to table row groups, rows, or columns. It does apply to cells and most other elements.
Compatibility
Browser Support
padding is a browser CSS property for the box model. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
padding
Supported in all modern browsers and Internet Explorer for many years. Part of the CSS Box Model.
99%Box model support
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera3.5+
Full support
Samsung Internet1+
Full support
Internet Explorer4+
Full support
paddingWidely supported
Bottom line: Safe for every layout. Logical longhands like padding-block are newer; the classic padding shorthand is universal. It is not a runtime API.
Remember
Key Takeaways
Role: inner spacing between content and border on all four sides.
Shorthand: 1–4 non-negative values map to sides (clockwise when four).
Background: the element’s background paints through the padding area.
Not margin: padding is inside; margin is outside. No auto, no negatives.
One line:padding sets space inside the border — use 1–4 lengths or percentages, never negative.
Frequently Asked Questions
It is a shorthand that sets the inner spacing on all four sides of an element — between the content and the border — by setting padding-top, padding-right, padding-bottom, and padding-left.
Each side defaults to 0. Elements start with no padding unless you set it or a browser stylesheet adds some (rare for padding).
Padding is space inside the border, between the border and the content. Margin is space outside the border, between this element and its neighbors.
Yes. Percentage padding is calculated from the containing block’s inline size (usually its width), even for top and bottom padding.
No. Negative lengths are invalid for padding. Use margin if you need to pull elements closer.
It is Baseline and widely available in all browsers. It is a browser CSS property for the box model, not a Node.js feature.