Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between using display: flow-root and overflow: hidden to contain floats?

Tags:

css

display

A new display value flow-root has been added to the css spec:

The element generates a block container box, and lays out its contents using flow layout. It always establishes a new block formatting context for its contents. [CSS2] – https://drafts.csswg.org/css-display/#valdef-display-flow-root

There are many ways to create a block context, e.g. overflow: hidden.

What is different about using display: flow-root vs overflow: hidden to contain float-ed elements?

like image 411
Gajus Avatar asked Apr 22 '17 12:04

Gajus


1 Answers

display: flow-root allows your flow root element to have overflow: visible if that's important to you, since block boxes with overflow: visible do not normally establish block formatting contexts.

like image 132
BoltClock Avatar answered Sep 20 '22 04:09

BoltClock