Skip to main content

Catalog / Layout

Box model
catalog.

Every visible UI element is a box. Change the values and watch how content, padding, border, margin, and overflow alter the space an element actually occupies.

Content area
268 x 160
marginborderpadding

Width lab

Change the box, then read the math

Content-box adds padding and border outside the declared width. Border-box keeps the declared width stable and shrinks the content area instead.

Read box sizing
Box sizing
Padding: 24px
Border width: 2px
Border style

Current calculation

320px border box

320px total, 268px content. With margin, the full occupied row is 384px.

Spacing

Gap aligns siblings; margin belongs to one box

A
B
C

Gap is owned by the parent layout, so all children stay even.

Overflow

What happens when content does not fit?

Long content needs a decision.

If the text is wider or taller than the box, the interface can show it outside, crop it, or make the box scrollable.

Overflow is not just CSS cleanup. It decides whether hidden content is accessible, clipped, or visually noisy.

Practical rule

Pick the spacing job first

If the space belongs inside the component, use padding. If it separates neighboring elements, use margin or parent-owned gap. If it marks the edge, use border.

Related terms