What Is Block Formatting Context (BFC) in CSS
Block Formatting Context (BFC) is a mini layout in the page. When an element establishes a BFC, it:
- includes internal floated elements
- exclude external floated elements
- suppresses margin collapsing
A BFC is created in many situations, see Block formatting context - CSS: Cascading Style Sheets | MDN. The simplest way to create a BFC is display: flow-root
.
Here is an example of excluding external floated elements (live preview):
|
|
|
|
Further reading:
- Block formatting context - CSS: Cascading Style Sheets | MDN
- Introduction to formatting contexts - CSS: Cascading Style Sheets | MDN
Comments powered by giscus. If comments are not loaded, giscus may be blocked by your Internet service provider.
Comments powered by Disqus. If comments are not loaded, Disqus may be blocked by your Internet service provider.