freecoding.school100% FREE · NO SIGNUP
Cascade FallsISSUE #20 of 33

padding · the inner space

StylaVSThe Specificity Sphinx
Styla sayspadding is the space inside an element, between its content and its border.

padding pushes content inward from the edge, inside any border, and takes the same 1-4 value shorthand as margin. Unlike margin it's never negative and shows the element's own background. It's what gives buttons and cards their comfortable inner breathing room.

Power-ups you unlock

The Specificity Sphinx attacks — common mistakes

Boss battleGive a button generous padding and a card uniform padding; compare to using margin.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>button{padding:10px 20px;font:inherit;background:#b388ff;border:0;border-radius:4px}</style></head><body style="background:#06040d;padding:20px"><button>padded button</button></body></html>
▶ Open the interactive comic issue
‹ Margin Collapse · The Surprising DefaultHeight And Width · Sizing Basics ›