Code · Made a little simpler

Spacing and Padding Visualizer

See how per-side margin, padding and border change a CSS box. Compare content-box and border-box sizing, then download the CSS.

Free to useNo account neededProcessed on your device
Your workspaceProcessed on your device

Use one to four values in CSS shorthand order. Four values run top, right, bottom and left.

Content
  • Margin
  • Border
  • Padding
  • Content
Content box
136 × 72 px
Border box
174 × 98 px
With margins
210 × 122 px

Add this tool to your website

Paste this code into your page to add the tool and a visible ToolMellow credit link.

HTML embed code
Preview embed

Spacing and Padding Visualizer: how to use it

  1. Enter width and height. Use one to four pixel values for margin, padding and border widths.
  2. Compare the colored layers and the content, border and margin-box measurements. Switch Box sizing to see which measurements change.
  3. Copy the CSS or download spacing-box.css. Apply the rule to a box in your layout and check its dimensions.

Limits and notes

Runs in your browser. Width is 16–480 px, height is 16–240 px and each spacing value is a nonnegative whole number from 0–48 px. The preview isolates one box and shows physical sides.

How your privacy works →

Spacing and Padding Visualizer: common questions

What are the four shorthand positions?

Enter top, right, bottom and left. Two values set top and bottom first, then left and right.

Does margin count toward border-box width?

No. Margins sit outside the border box. Border-box sizing counts the content, padding and border in the specified width when they fit.

What happens if the padding and borders exceed the width?

The content width reaches zero. The border box can still grow beyond the specified width to fit the padding and borders.

Guides