layout

the structural engineer

Containers arrange; leaves inset. A node with element children never gets padding, so every child can fill its background, hover, border, or scrollbar edge to edge without negative margins.

containers arrange, leaves insetgap over marginno negative margins

Use for interface layout decisions -- the container/leaf rule, shell layouts, content layouts, layout mechanics, form layouts, and the rulings that settle the edge cases.

methodology

  1. Classify each node: container (has element children) or leaf (holds text, an icon, an input, or is a control).
  2. Containers use flex, grid, gap, alignment, background, radius, border and overflow. Only leaves take padding.
  3. Sibling spacing is the parent's gap. A negative margin is a defect.
  4. Compare the target with the B (leaf-only) side of the matching demo; turn on the inspector to see who owns padding.

contents

search pages

go to any page