CSS padding Property
The padding shorthand property sets the padding area on all four sides of an element inside its border.
Description & Usage
The padding property creates space inside an element between its text/content and its outer border line.
Unlike margin, padding inherits the background color and background image of the element container.
Increasing padding is essential for touch targets, buttons, and readable card containers, giving content room to breathe.
Property Specifications
| Property Feature | Specification |
|---|---|
| Category | Box Model |
| Initial Value | 0 |
| Inherited | No (not inherited) |
| Applies To | All elements except table-row-group, table-header-group, etc. |
Syntax
padding: 10px | 10px 20px | 10px 20px 30px 40px;Property Values
| Value | Description |
|---|---|
| 1rem | 1rem padding on top, right, bottom, left. |
| 0.5rem 1rem | 0.5rem top/bottom, 1rem left/right. |
Code Examples
Button Click Area Padding
.btn {
padding: 0.75rem 1.5rem;
border-radius: 6px;
}
Increases comfortable touch/click area inside button border.