Skip to the page
css reference · the box model

CSS padding

type
property
applies to
any element
inherits
no
common values
0, 16px, 1rem, 8px 16px

Where it goes

On any box whose content sits too close to its own edge.

Example

.button {
  padding: 10px 20px;
}

Common mistakes

  • Using margin when padding was meant, or the other way round. Margin pushes other boxes away. Padding gives the content inside more room.
  • Forgetting box-sizing: border-box, then being surprised that padding made the box wider than the width you set.

Related

Updated 24 October 2026. Practice it in the css route, or read more on MDN.