Skip to main content

Flexbox and Grid for CSSs

Flexbox and Grid are CSS's two modern layout systems. Flexbox arranges items in one dimension, a row or a column, with control over alignment, spacing and growth. Grid arranges items in two dimensions with rows and columns, so it suits whole page layouts and card galleries.

Stage: Layout · Part of the CSS roadmap · Last reviewed 19 November 2026

What to learn in Flexbox and Grid

Flexbox and Grid interview questions

When should you use Grid instead of Flexbox?

Use Flexbox for a single row or column where content determines sizes, such as navigation bars. Use Grid when you need to control rows and columns together, like page layouts or galleries. They are often combined, with Grid for structure and Flexbox inside items.

What is the difference between justify-content and align-items in Flexbox?

justify-content distributes items along the main axis, which is horizontal by default. align-items aligns them along the cross axis. Changing flex-direction to column swaps which physical direction each one affects.

Where Flexbox and Grid fits in the CSS roadmap

Flexbox and Grid belongs to the Layout stage (beginner level), which takes about 17 hours. Place things on the page.

Back to the full CSS roadmap