Block Formatting Context (BFC) vs CSS Logical Properties
BFCs isolate vertical margin collapse and floats, whereas logical properties orient box edges to writing mode.
Structured Comparison Matrix
| Dimension | Block Formatting Context (BFC) | CSS Logical Properties |
|---|---|---|
| Mental Model | Stop parent-child vertical margin collapse and zero-height float wrappers without clipping shadows—display: flow-root isolates a box's layout region. | Logical properties (inline-start, block-end) map margins, padding, and borders to writing-mode and direction automatically. |
| Maturity & Domain | Baseline · Widely · CSS & Layout Chrome 58+ · Firefox 53+ · Safari 13+ | Baseline · Widely · CSS & Layout Chrome 87+ · Firefox 66+ · Safari 14.1+ |
| Prerequisites | ||
| When Not to Use | When not to use display: flow-root: If the container already uses display: flex or display: grid, its children already live inside flex/grid formatting contexts, flow-root is redundant. | When not to use logical properties: Do not use logical directions for inherently physical geometry (like a compass rose or video scrubber bar that always runs left-to-right). |
Engine Mechanics & Trade-Offs
Each BFC maintains its own float exclusion list and prevents vertical margins from collapsing across its boundary.
Key Pitfalls: Accidental clipping with overflow: hidden: Using overflow: hidden solely for a BFC slices off box-shadow, focus outlines, and position: sticky descendants. Unexpected margin collapse: A margin-top on the first heading inside a <section> escapes above the section's background unless a BFC or padding intervenes.
Engine maps inline-start/end and block-start/end to physical top/right/bottom/left based on direction (ltr/rtl) and writing-mode.
Key Pitfalls: Mixing physical and logical: Writing margin-inline: 0 above margin-left: 1rem maps to the same underlying box-model slot, causing confusing cascade overrides. Logical overflow-x gotcha: overflow-inline is newer than margin-inline; verify support before replacing overflow-x if targeting older browsers.