How to understand CSS — BFC

aifou
5 min readMar 12, 2024

Normal flow

In normal flow, boxes are placed sequentially. In a block formatting context, boxes are arranged vertically, while in an inline formatting context, boxes are arranged horizontally. When the CSS position property is static or relative, and float is none, the layout is in normal flow.

https://www.w3.org/TR/CSS2/visuren.html#block-formatting

Boxes in the normal flow belong to a formatting context, which may be block or inline, but not both simultaneously. Block-level boxes participate in a block formatting context. Inline-level boxes participate in an inline formatting context.

FC

https://drafts.csswg.org/css-display/#formatting-context

A formatting context is the environment into which a set of related boxes are laid out. Different formatting contexts lay out their boxes according to different rules.

Formatting context is the environment that determines how boxes are laid out. Different formatting contexts layout boxes according to their own rules.

BFC

https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Block_formatting_context

Block Formatting Context (BFC) is a part of the visual CSS rendering of a web page, where the layout process of block-level boxes occurs, and it’s also the area where floating elements interact with other elements.

BFC rules

--

--