Dev Helpers

CSS / Box model and sizing

Content-box sizing

Dev Helpers · October 13, 2025

Content-box sizing assigns the declared size to the content area. Padding and borders increase the final occupied space.

Worked example

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

Implementation notes

Mixing sizing models within one component makes measurements hard to compare. Inspect the computed box model on both the parent and the measured child.

Try it yourself

Give two boxes the same width but different horizontal padding.

Open the CSS example →

Editorial date October 13, 2025 · 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.