In terms of how these new values help to clarify CSS layout, we can take a look at a couple of values in the table that might seem less familiar. The multi-keyword display: block flow-root
maps to a fairly recent single value; display: flow-root
. This value's only purpose is to create a new Block Formatting Context (BFC). A BFC ensures that everything inside your box stays inside it, and things from outside the box cannot intrude into it. The most obvious use-case for creating a new BFC is to contain floats, and avoid the need for clearfix hacks.
In the example below we have a floated item inside a container. The float is contained by the bordered box, which wraps it and the text alongside. If you remove the line display: flow-root
then the float will poke out of the bottom of the box. If you are using Firefox you can replace it with the newer display: block flow-root
, which will achieve the same as the single flow-root
value.
The flow-root
value makes sense if you think about block and inline layout, which is sometimes called normal flow. Our HTML page creates a new formatting context (floats and margins cannot extend out from the boundaries) and our content lays out in normal flow, using block and inline layout, unless we change the value of display
to use some other formatting context. Creating a grid or flex container also creates a new formatting context (a grid or flex formatting context, respectively.) These also contain everything inside them. However, if you want to contain floats and margins but continue using block and inline layout, you can create a new flow root, and start over with block and inline layout. From that point downwards everything is contained inside the new flow root.
The multi-keyword syntax for display: flow-root
being display: block flow-root
therefore makes a lot of sense. You are creating a block formatting context, with a block-level box and children participating in normal flow. What about the matched pair display: inline flow-root
? This is the new way of describing display: inline-block
.
The value display: inline-block
has been around since the early days of CSS. The reason we tend to use it is to allow padding to push inline items away from an element, when creating navigation items for example, or when wanting to add a background with padding to an inline element as in the example below.
An element with display: inline-block
however, will also contain floats. It contains everything inside the inline-level box. Therefore display: inline-block
does exactly what display: flow-root
does, but with an inline-level, rather than a block-level box. The new syntax accurately describes what is happening with this value. In the example above, you can change display: inline-block
to display: inline flow-root
in Firefox and get the same result.