- Home
- /
- CSS Padding
CSS Tutorial
Introduction
CSS Properties
CSS Designing
CSS Advance Topics
CSS FAQs
- Home
- /
- CSS Padding
CSS Padding
Padding in CSS adds space between an element’s content and its border. Think of it as inner spacing that keeps content from touching the edge.
What is Padding?
Padding is the internal gap between the content and the element’s edge.
Visual Tip:
Imagine a button. Padding controls how much space is around the text inside the button — not outside.
Basic Syntax
selector {
padding: value;
}
You can define padding in
px
,em
,%
, orrem
.This applies the same padding to all four sides: top, right, bottom, left.
Example 1: Equal Padding on All Sides
Learn With Arshyan - Equal Padding

Vertical & Horizontal Padding
You can also define vertical and horizontal padding separately using two values:
selector {
padding: vertical horizontal;
}
Example 2: Vertical and Horizontal Padding
This text has vertical (10px) and horizontal (40px) padding.

Padding on Each Side
Use four values to control each side individually:
selector {
padding: top right bottom left;
}
Example 3: Padding on All Sides Differently
Custom padding on each side!

Inspecting Padding in Browser
Right-click the element.
Click Inspect.
View the Box Model under Computed Styles.
Hover over padding areas to see how space is applied.