Padding (CSS)

Padding is the space between an element's content and its border, inside the box. It pushes the content inward, away from the edges.

Web

Padding is great for giving buttons, cards, and containers breathing room so their text isn't cramped against the edge. Unlike margin, padding takes on the element's background color.

You can set padding for all sides at once (padding: 10px) or per side (padding-top, padding-left, etc.).

Examples

CSS

.button {
  padding: 12px 24px;
  background: steelblue;
}

Output:

Renders a button with 12px of vertical and 24px of horizontal space around its text.

Learn it in a lesson

See also

Back to the Dictionary