Flex-direction
The CSS flex-direction property specifies the main-axis direction and ordering in which flex items are laid out within a flex container.
Web Design Playground, Second Edition
The CSS flex-direction property specifies the direction in which flex items are placed along the main axis of a flex container.
- How it is used
- Chooses whether a flex container’s items run horizontally or vertically.
- How deep it goes
- Defines the main and cross axes, lists four direction values, and identifies the default; leaves alignment to separate properties.
- Examples
- Shows direction values in CSS and uses a column layout to place photo captions below thumbnails.
- What you can do after
- Apply it via CSS to choose a flex container’s item direction, including a vertical thumbnail-and-caption layout.
Read how Web Design Playground, Second Edition explains flex-direction →
Web Design Playground
A CSS flexbox property that sets the direction of the main axis and the order in which flex items flow.
- How it is used
- Sets the direction of flex items in page layouts, including nested containers in a portfolio.
- How deep it goes
- Defines the main and cross axes and all four direction values, then applies row and column in a layout.
- Examples
- Uses div layouts with reversed directions and a portfolio with a centered row containing a top-aligned column.
- What you can do after
- Operate/configure it by choosing row or column flow for flex containers and reversing that flow when needed.
CSS in Depth, Second Edition
The CSS flex-direction property specifies the main-axis direction and ordering of flex items in a flex container.
- How it is used
- Controls whether flex items flow horizontally, vertically, or in reverse order within a flex container.
- How deep it goes
- Explains axis rotation, nested containers, and height-dependent growth, while deferring broader alignment and spacing options.
- Examples
- Uses a two-column page with a taller main tile and vertically stacked sidebar tiles that must align at the bottom.
- What you can do after
- Apply it via CSS to stack, reverse, or redistribute flex items and to build height-filling nested layouts.
Read how CSS in Depth, Second Edition explains flex-direction →
Also covered in
What to know first
- display propertyThe CSS property that specifies how an element generates boxes and participates in layout.
- flexboxFlexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
Related concepts
- flex-flowconfigured by · The CSS flex-flow property is a shorthand that sets a flex container's flex-direction and flex-wrap properties.
- flex containerconfigures · A flex container is an element whose children are laid out as flex items according to the CSS Flexible Box Layout model.
- flexboxconfigures · Flexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
- main axisconfigures · The main axis is the primary direction in which a flex container arranges and distributes its flex items.
- columnconfigures · A column is a vertical sequence or region of cells or entries in a table, grid, or matrix; in tabular data, it represents one attribute across records.
Questions about flex-direction
What is flex-direction?
The CSS flex-direction property specifies the main-axis direction and ordering in which flex items are laid out within a flex container.
Which Manning books explain flex-direction?
Web Design Playground, Second Edition, Web Design Playground and CSS in Depth, Second Edition.
What should I know before learning flex-direction?
Manning books that teach flex-direction usually introduce display property and flexbox first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


