On this page
Box Model & Formatting Contexts
Prev: Cascade, Specificity & Inheritance | Up: tutorials | Next: Modern Layout: Flexbox & Grid
Rel: Box Model & Sizing, Positioning & Stacking
Ref: MDN Web Docs — Block Formatting Context
Tags: #public #web #css #tutorials #box-model
Contents
Box Edges & Margin Collapsing
Every rendered element generates a box with four concentric areas: content -> padding -> border -> margin.
In normal block flow, adjacent vertical margins collapse into the larger of the two (rather than adding). Margins do not collapse inside Flex or Grid containers, or across padding/borders.
Block Formatting Contexts (BFC)
A Block Formatting Context is an isolated layout region that contains floats and prevents internal margins from collapsing out of its parent. Create a clean BFC without side effects using:
.section {
display: flow-root;
}
Linked from
Related notes
- tuts/css/tutorials Linked here; links to this page; shared tags: #css, #tutorials, #web
- tuts/css/tutorials/cascade_specificity_and_inheritance Linked here; links to this page; shared tags: #css, #tutorials, #web
- tuts/css/tutorials/modern_layout_flexbox_and_grid Linked here; links to this page; shared tags: #css, #tutorials, #web
- tuts/css/properties/box_model_and_sizing Linked here; links to this page; shared tags: #css, #web
- tuts/css/properties/positioning_and_stacking Linked here; links to this page; shared tags: #css, #web
- tuts/css/properties links to this page; shared tags: #css, #web
- tuts/css/tutorials/responsive_design_and_theming shared tags: #css, #tutorials, #web
- tuts/css shared tags: #css, #web
- tuts/css/at_rules shared tags: #css, #web
- tuts/css/at_rules/keyframes_and_fonts shared tags: #css, #web