CSS padding-top Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The padding-top property sets the height of the padding area on the top of an element. That space sits between the content and the top border.

It always targets the physical top edge. For spacing that follows writing mode, use padding-block-start. To set all sides at once, use the padding shorthand.

Standard-track.

Not deprecated and not experimental. A long-standing CSS box-model property with universal browser support.

CSS Syntax

syntax.css
padding-top: <length> | <percentage> | initial | inherit;

Lengths and percentages must be non-negative. The initial value is 0.

Property Values

ValueDescriptionTry it
<length>Fixed padding such as 20px, 1rem, or 2emTry it
<percentage>Percent of the containing block’s width (not height)Try it
initialResets to 0Try it
inheritTakes the parent’s padding-topTry it

How to Use padding-top

Add space inside the top border when you specifically need the physical top side.

  1. Choose a non-negative length or percentage.
  2. Set it on the element that needs top inner space.
  3. Remember: padding is inside the border; margin is outside.
  4. Use padding-block-start instead when the layout must follow writing mode.
PieceRequired?Role
Element that accepts paddingYesSome table display types ignore padding
Length or percentageYesMust be 0 or greater
Containing block widthFor %Even top percentages resolve against width
Border (optional)HelpfulMakes the top padding gap easy to see

Live Preview

Change padding-top on a bordered box. The gap always appears on the physical top.

Padding sits between the content and the top border. It does not move the border itself.

Box
Top padding here

padding-top: 2rem

CSS Examples

Each snippet focuses on padding-top. Use Try It Yourself for a live editor.

Example 1 — Length Padding

Add 2rem of space between the content and the top border.

CSS
<style>
  div {
    padding-top: 2rem;
    border: 1px solid black;
  }
</style>

<div>Top padding here</div>
Try It Yourself

How It Works

  1. Pick a length. 2rem is the top inner gap.
  2. Physical top only. The gap stays on the top edge of the box.
  3. Content shifts down. Text starts after that 2rem space.
  4. Border stays outside. Padding sits between content and the border edge.

Example 2 — Percentage Padding

Size top padding as a share of the parent width.

CSS
<style>
  div {
    padding-top: 10%;
    border: 1px solid black;
  }
</style>

<div>10% top padding</div>
Try It Yourself

How It Works

  1. Use a percentage. 10% looks vertical, but it is based on width.
  2. Containing block width. A wider parent makes a larger top padding.
  3. Common surprise. Top and bottom percentages do not use the parent height.
  4. Still non-negative. Negative percentages are invalid for padding.

Example 3 — Zero vs Padded

Compare no top padding with a clear 2rem gap.

CSS
<style>
  .none {
    padding-top: 0;
    border: 1px solid black;
  }

  .pad {
    padding-top: 2rem;
    border: 1px solid black;
  }
</style>

<div class="none">No top padding</div>
<div class="pad">2rem top padding</div>
Try It Yourself

How It Works

  1. Default is zero. With 0, content sits against the top border.
  2. Add a gap. 2rem pushes the content downward.
  3. Same border, different padding. Only the inner space changes.
  4. Not margin. The outer position of the box stays the same; only the inside shifts.

Edge Cases & Pitfalls

Most top-padding bugs come from percentages or mixing padding with margin.

percent

Percentage uses width, not height

padding-top: 10% is 10% of the containing block’s width. It is not based on the parent height.

margin

Padding is inside; margin is outside

padding-top pushes content away from the top border. margin-top pushes the whole box away from the element above.

logical

Physical top ignores writing mode

In vertical writing, “start” may not be top. Prefer padding-block-start for writing-mode-aware spacing.

negative

Negative values are invalid

Padding cannot be negative. Use a negative margin if you need to pull an element upward.

box

box-sizing changes the total size

With border-box, top padding is included inside the declared height. With content-box, it adds outside the content height.

Browser Support

padding-top is a browser layout property. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

padding-top

Length and percentage values work in all major browsers, including older Internet Explorer versions.

99% Common values
Google Chrome 1+
Full
Mozilla Firefox 1+
Full
Apple Safari 1+
Full
Microsoft Edge 12+
Full
Opera Supported
Full
Samsung Internet Supported
Full
Internet Explorer 4+
Full
padding-top Widely supported

Bottom line: Safe for everyday top padding in every current browser.

Key Takeaways

  • Role: add inner space on the physical top edge, between content and border.
  • Common values: lengths and percentages (never negative).
  • Initial value: 0. Not inherited.
  • Percent tip: top percentages resolve against the parent width.

One line: padding-top is physical top inner space — always top, never negative.

Frequently Asked Questions

It sets inner spacing on the top edge of an element, between the content and the top border.
The initial value is 0. No top padding is added until you set a length or percentage.
padding-top adds space inside the border. margin-top adds space outside the border, between this element and the one above it.
padding-top always targets the physical top edge. padding-block-start follows writing mode, so it can map to a different physical side in vertical text.
No. A percentage is relative to the containing block's width (inline size), even for top padding. That surprises many beginners.
It is Baseline and widely available in all major browsers, including older Internet Explorer versions. It is a browser layout property, not a Node.js feature.

Next: page-break-after

Learn how print layouts control page breaks after an element.

page-break-after tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful