Description & Usage

The flex-direction property establishes the main axis of a flex container, dictating whether flex items are laid out horizontally in rows or vertically in columns.

By switching between row and column, developers can easily create responsive designs that transform horizontal navigation bars on desktop into stacked vertical menus on mobile devices with minimal code changes.

Using row-reverse or column-reverse flips the visual order and start/end points of flex items, allowing right-to-left layout adjustments or inverted stacking order.

Property Specifications

Property FeatureSpecification
CategoryFlexbox
Initial Valuerow
InheritedNo (not inherited)
Applies ToFlex containers (display: flex or inline-flex)
Flexbox Playground
Items:
4
12px
Item 1
Item 2
Item 3
Item 4
.container { display: flex; flex-direction: row; justify-content: center; align-items: center; flex-wrap: nowrap; gap: 12px; }

Syntax

flex-direction: row | row-reverse | column | column-reverse;

Property Values

ValueDescription
rowItems are laid out horizontally in line direction (left to right in LTR).
row-reverseItems are laid out horizontally in reverse direction (right to left).
columnItems are stacked vertically from top to bottom.
column-reverseItems are stacked vertically from bottom to top.

Code Examples

Vertical Column Navigation
.nav-menu { display: flex; flex-direction: column; gap: 1rem; }
Stacks menu links vertically in a sidebar.