New:Embedded & IoT Bootcamp
Tutorial 23 of 44 in series

CSS Padding

Add space inside elements

Abhishek Sharma 2026-05-30 Web Development / Frontend / CSS
52%

Padding

Padding is the space between an element’s content and its border. It creates breathing room inside the element.

Demo: Padding Comparison
HTML
<div class="no-padding">No padding</div>
<div class="padding">With padding</div>
<div class="uneven">Uneven padding</div>
CSS
div { width: 200px; border: 2px solid #6366f1; margin: 4px 0; background: #eef2ff; }
.no-padding { padding: 0; }
.padding { padding: 20px; }
.uneven { padding: 10px 30px; }
Live Output Window

Padding Shorthand

/* All four sides */
padding: 10px;

/* top/bottom | left/right */
padding: 10px 20px;

/* top | left/right | bottom */
padding: 10px 20px 15px;

/* top | right | bottom | left */
padding: 10px 15px 20px 25px;

Individual Properties

Property What It Sets
padding-top Space above content
padding-right Space to the right
padding-bottom Space below content
padding-left Space to the left

Padding is inside the border - it increases the element’s total visible size unless box-sizing: border-box is used.

Keep learning

Related tutorials from across the library.

All tutorials
Tutorial2026-05-30

Introduction to CSS

Learn what CSS is and why it matters

Web Development / Frontend / CSS

CSSWeb Development
Tutorial2026-05-30

History of CSS

Understand how CSS evolved

Web Development / Frontend / CSS

CSSWeb Development
Tutorial2026-05-30

Adding CSS

Three ways to add CSS to a page

Web Development / Frontend / CSS

CSSWeb Development