Dev Helpers

CSS / Box model and sizing

Border-box sizing

Dev Helpers · January 14, 2026

Border-box sizing includes padding and borders in a declared width. This is useful when several cards must share a precise grid.

Worked example

<style>
  .demo {
    box-sizing: border-box;
    width: 12rem;
    padding: 1rem;
    border: 4px solid teal;
  }
</style>
<div class="demo">Border-box sizing</div>

Implementation notes

The declared width still excludes margin. Two border-box columns that add up to a full row can overflow once external margins or gaps are included.

Try it yourself

Add a thicker border and measure the outside edge.

Open the CSS example →

Editorial date January 14, 2026 · Published December 6, 2026

Related articles

Fluid width with a maximum

A fluid container needs a small-screen width and a large-screen maximum. Outer gutters should remain visible at both extremes.

Square aspect ratio

A square ratio reserves equal sides even before media loads. Fit rules decide whether rectangular content is cropped or letterboxed.

Minimum inline size

A logical minimum inline size protects a component from collapsing beyond its usable width. An overly large minimum can force overflow.