When it comes to block formatting context (using display: block
), block elements automatically occupy the entire width of their parent, causing them to stack vertically.
According to the specification:
9.4.1 Block formatting
contexts
In a block formatting context, boxes are placed one by one, vertically, starting at the top of the container block.
In a flex formatting context (using display: flex
), specifically with flex-direction: column
, items are also stacked vertically, mimicking the behavior of display: block
.
Although the layout appears to be the same, it's important to note that the flex-direction
property is not considered when in a block formatting context.