CSS Grid or Flexbox? Choose by layout direction

CSS Grid and Flexbox are often presented as competing layout systems. They are not. The useful question is whether the part of the page you are arranging is mainly one-dimensional or two-dimensional.

Flexbox follows one main axis

Flexbox lays items out in a row or a column. It is a good fit when content size should influence the layout: navigation links, buttons in a toolbar, or a group of cards that can wrap.

Its core controls cover the common alignment problems:

Grid controls rows and columns together

Grid gives you rows and columns at the same time. Use it when the relationship between both axes matters, such as a page shell, a dashboard, or cards whose columns should line up across multiple rows.

The main tools are:

A practical rule

Start with the shape of the problem:

This is a starting point, not a law. A wrapped Flexbox layout can create several rows, and Grid can handle a single row perfectly well. The difference is which model makes the intended relationship easier to express.

For example, I would usually use Flexbox for a navigation bar because the links form one group along a row. A newspaper-like layout with aligned columns is more naturally a Grid.

Using both is normal

The choice does not have to apply to the whole page. A page can use Grid for its main content and sidebar, then Flexbox inside the header or each card.

I would not choose one because it is supposedly simpler or more modern. Sketch the relationship between the items, pick the layout model that describes it directly, and let the two systems work together when the page needs both.