Main axis
The main axis is the primary direction in which a flex container arranges and distributes its flex items.
Web Design Playground, Second Edition
The main axis is the primary direction in which a flex container arranges its flex items.
- How it is used
- Guides the direction and arrangement of flex items in containers and nested page layouts.
- How deep it goes
- Defines the axis, shows how to select its direction, and applies it in a page layout; defers fuller two-dimensional layout to CSS Grid.
- Examples
- Uses direction choices and a layout with a stacked body, side-by-side header and navigation items, and article and sidebar columns.
- What you can do after
- Build it from scratch by choosing vertical or horizontal flex containers and arranging items along their main axes.
Read how Web Design Playground, Second Edition explains main axis →
CSS in Depth, Second Edition
The main axis is the primary direction in which a flex container lays out and distributes its flex items.
- How it is used
- Explains how flexbox places, sizes, spaces, and wraps items along their primary layout direction.
- How deep it goes
- Defines the axis, follows its rotation through flex-direction, and explains sizing, spacing, wrapping, and height constraints.
- Examples
- Uses navigation, tiles, a nested sidebar column, axis diagrams, and spacing and wrapping property examples.
- What you can do after
- Apply via CSS Flexbox to choose flow direction, predict sizing dimensions, distribute space, and diagnose constrained column layouts.
Web Design Playground
The primary flexbox axis running top to bottom along which flex items are arranged when the container is vertical.
- How it is used
- Organizes flex items by identifying their direction of travel within a flex container.
- How deep it goes
- Defines the main axis against the cross axis and applies vertical direction and start alignment in page layouts.
- Examples
- Uses a holy-grail page layout and a photo gallery with vertically stacked body content.
- What you can do after
- Apply it via CSS flex-direction: column and justify-content: flex-start to stack page elements from the top.
Also covered in
What to know first
- body elementThe HTML body element contains the content of a document intended for display in a browser.
- flexboxFlexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
- footer sectionA footer is a region associated with a document or section that contains closing or supplementary content, often positioned at the bottom.
- navigationNavigation is the process and structure that enables users to move among pages, sections, views, or other destinations in a digital system.
Related concepts
- justify-contentused by · The CSS justify-content property distributes flex items or grid tracks along the relevant container axis when free space is available.
- cross axiscontrasts with · The layout axis perpendicular to a flex container's main axis, along which items can be aligned.
- flex-directionconfigured by · The CSS flex-direction property specifies the main-axis direction and ordering in which flex items are laid out within a flex container.
- flex itemhas part · A flex item is a child of a flex container that participates in its flexible layout.
- flexboxused by · Flexbox is a CSS one-dimensional layout model for arranging, sizing, aligning, and distributing items along a row or column.
Questions about main axis
What is main axis?
The main axis is the primary direction in which a flex container arranges and distributes its flex items.
Which Manning books explain main axis?
Web Design Playground, Second Edition, CSS in Depth, Second Edition and Web Design Playground.
What should I know before learning main axis?
Manning books that teach main axis usually introduce body element, flexbox, footer section and navigation first.
What is the difference between main axis and cross axis?
The main axis is the primary direction in which a flex container arranges and distributes its flex items. The layout axis perpendicular to a flex container's main axis, along which items can be aligned.
What are the parts of main axis?
Main axis includes flex item.
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.


