Padding
Adds space inside an element's borders, between the element's content and its border. Padding creates breathing room within components, improves readability, and makes UI elements more touchable. Tailwind's padding utilities follow a consistent spacing scale based on 0.25rem (4px) increments that create harmonious, proportional spacing throughout your design.
Spacing2 variants4 examples
Basic usage:
<div class="p-4 bg-blue-100 rounded">Padding on all sides (1rem)</div>
Examples
<div class="p-4 bg-blue-100 rounded">Padding on all sides (1rem)</div>
<div class="px-4 py-2 bg-green-100 rounded">Horizontal and vertical padding</div>
<div class="pt-8 pr-4 pb-12 pl-4 bg-yellow-100 rounded">
Different padding on each side
</div>
<!-- Responsive padding example -->
<div class="p-4 md:p-8 lg:p-12 bg-purple-100 rounded-lg">
<h2 class="text-xl font-bold mb-4">Card Title</h2>
<p>This card has padding that increases on larger screens, providing appropriate spacing for different devices.</p>
</div>
Live Preview
Try the Padding utility with different values
Variants
p: all sides, px: left and right (horizontal), py: top and bottom (vertical), pt: top only, pr: right only, pb: bottom only, pl: left only
ppxpyptprpbpl