๐Ÿ”
๐Ÿ‘ถ Kids๐Ÿ“ Blog About Contact ๐Ÿš€ Get Started Free

CSS Padding

The CSS padding properties are used to generate space around an element's content, inside of any defined borders.

Padding is the transparent space inside an elementโ€™s border โ€” between the border and the actual content. More padding = more breathing room for your content.

Try It โ€” Padding in Action

Preview

Padding Shorthand

ShorthandSets
padding: 20pxAll 4 sides = 20px
padding: 10px 30pxTop & Bottom = 10px, Left & Right = 30px
padding: 10px 20px 30px 40pxTop, Right, Bottom, Left (clockwise)

Padding vs Margin

PaddingMargin
LocationInside the borderOutside the border
BackgroundShows elementโ€™s backgroundAlways transparent
CollapseDoes not collapseAdjacent margins collapse

Tip: When you need space inside a button or card, use padding. When you need space between two elements, use margin.