Inner space
Padding keeps content away from the component edge.
Padding is inside spacing. It creates comfort between content and the visible edge of a component.
.button {
padding-block: .75rem;
padding-inline: 1.25rem;
}
Box Model
Padding lives between content and border. It is the reason a button feels clickable, a card feels premium and text does not crash into the edge of its container.
Unlike margin, padding belongs to the component itself. If the component moves, its padding moves with it.
Good padding often uses a spacing scale and responsive values. It should support readability, touch comfort and visual hierarchy.
Padding keeps content away from the component edge.
Buttons and links need enough padding to feel clickable.
clamp() can make padding adapt without many breakpoints.
Padding increases the visible background area of a box.
Visual model
Layout debugging becomes much easier when you can point to the exact part of the box that creates the visual result: inner space, outer space, edge, size or overflow behavior.
Inline and block padding create a real click target.
Text needs space around it to feel intentional.
Page sections need padding so content does not touch screen edges.
Examples
.button {
display: inline-flex;
min-height: 44px;
align-items: center;
padding-inline: 1.25rem;
}
.button {
padding: 2px 4px;
line-height: 1;
font-size: 12px;
}
Rules that matter
Box model CSS should make the interface easier to reason about. When a value cannot be explained, it usually becomes a future layout bug.
If text touches an edge, padding is probably missing.
Interactive controls need enough height and width to be usable.
padding-block and padding-inline make intent clearer.
Repeated spacing values make components feel connected.
clamp() helps padding feel right on mobile and desktop.
Padding can affect final size unless border-box is in use.
Production thinking
Padding is one of the quickest ways to separate cheap-looking UI from polished UI. It controls comfort.
Adequate padding helps users tap controls, read labels and see focus states.
Component padding should be deliberate and reusable. Avoid random one-off padding that only works for one label.
Comfortable reading and clicking improves user experience, especially on mobile search traffic.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If the answer is vague, change the lab CSS and inspect the box again.
Senior audit upgrade
padding-left and padding-right work, but padding-inline and padding-block describe direction by writing flow instead of physical side.
Controls start and end inline space, useful for LTR and RTL.
Controls top and bottom in horizontal writing modes.
Use logical properties for components that may need international layouts later.