Zero Signup ToolsFree browser tools

Generator Tools

CSS Box Model Visualizer

Visualize and calculate the CSS box model in your browser. Set content size, padding, border, and margin and get copyable CSS and Tailwind classes.

Quick presets

Live box model

1:1 scale
MarginBorderPaddingContent

Computed box sizes

Each row shows the final outer dimensions for that part of the box.

Content
320px x 160px
Padding box
368px x 192px
Border box
372px x 196px
Margin box
404px x 228px

Horizontal: padding 48px + border 4px + margin 32px.

Vertical: padding 32px + border 4px + margin 32px.

box-sizing

content-box: width targets the content area. border-box: width includes padding and border.

Dimensions

Unit
px

Root font size is used to convert rem and em values for the live preview and the copied CSS. 16px is the browser default.

Padding

16px 24px

Border width

2px

Margin

16px

CSS (shorthand)

width: 320px;
height: 160px;
box-sizing: content-box;
padding: 16px 24px;
border-width: 2px;
border-style: solid;
margin: 16px;

Paste-ready inside any selector. border-style is included so the border actually renders; change the value or add border-color to match your design.

CSS (longhand)

width: 320px;
height: 160px;
box-sizing: content-box;
padding-top: 16px;
padding-right: 24px;
padding-bottom: 16px;
padding-left: 24px;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 2px;
border-left-width: 2px;
border-style: solid;
margin-top: 16px;
margin-right: 16px;
margin-bottom: 16px;
margin-left: 16px;

One property per side. Useful when a build system requires explicit properties or when you need to override a single side.

Tailwind v3+ classes

w-[320px] h-[160px] box-content py-[16px] px-[24px] border-[2px] m-[16px]

Uses arbitrary values so any pixel or rem value round-trips. Add the base "border" class so Tailwind sets border-style for you.

How to use

  1. Pick a preset (Card, Button, Input field, Hero image, or Vertical stack item) to load a sensible starting point, or start from the default values.
  2. Choose box-sizing: content-box if width targets the content area, or border-box if width includes padding and border.
  3. Adjust width and height. Switch between px, rem, and em with the unit toggle. Set the root font size to match your project for accurate rem and em output.
  4. Edit padding, border width, and margin per side. Use the Link all four sides toggle on each group to keep top, right, bottom, and left in sync.
  5. Read the live diagram for side labels and the computed-box summary for content, padding, border, and margin box sizes.
  6. Click Copy CSS, Copy longhand, or Copy classes to put the shorthand block, the longhand block, or the Tailwind classes on your clipboard.

About this tool

CSS Box Model Visualizer is an interactive tool that draws the four CSS box areas (content, padding, border, margin) as nested rectangles and recomputes them in real time as you edit any side. It teaches and applies the same rules the browser uses, so the numbers in the panel match what DevTools would show for an element with the same declared properties. Pick content-box (the CSS default, where width targets the inner content area and padding plus border are added outside it) or border-box (the modern normalization, where width targets the border box and padding plus border are absorbed from the inside). Set width, height, the four padding sides, the four border-width sides, and the four margin sides; toggle Link all four sides per group to edit a single value that propagates to top, right, bottom, and left; switch between px, rem, and em with a configurable root font size so the rem and em outputs match your project. The diagram scales the largest dimension to fit the canvas with side labels for each non-zero padding and margin value, and the summary panel reports the computed content, padding, border, and margin box sizes plus the horizontal and vertical totals so you can confirm an outer width target. Three copyable outputs are kept in sync as you edit: a paste-ready CSS shorthand block (width, height, box-sizing, padding, border-width, border-style, margin), a longhand block with one property per side for build systems that require explicit properties or single-side overrides, and a Tailwind v3+ string with arbitrary values that round-trips any pixel or rem amount. Includes presets for common shapes (card, button, input, hero image, vertical stack item) and a warning when the declared border-box width is too small to fit the requested padding and border. Useful for learning how padding, border, margin, and box-sizing interact; planning a card or panel without trial-and-error in DevTools; converting a design system token list into ready-to-paste CSS or Tailwind classes; and double-checking whether a width includes or excludes padding in a legacy stylesheet. Everything runs locally on your device, so the values you enter here never leave your browser.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsGenerator Tools