Skip to main content
D
CSS
CSS Padding

CSS Padding

CSS padding creates empty space inside an element.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

CSS generates transparent space inside the border of an element, pushing its content inward. Developers use padding to give text breathing room so it doesn't touch the borders. You can set padding for all four sides.

Syntax

Syntax
1/* padding syntax */
2div {
3  padding: 20px;
4}

Example

Example
1/* this adds padding */
2p {
3  padding-top: 10px;
4  padding-left: 15px;
5  border: 1px solid black;
6}

Key Points

  • Padding sits inside the element's border.
  • The padding area inherits the background color.
  • Padding pushes the inner content inward.
  • The `padding` shorthand sets all four sides at once.

Up Next

Continue your journey with the next topic.

Go to CSS Height/Width