← All Quizzes
When should you use Flexbox vs CSS Grid for layout?
Explanation
Use Flexbox for one-dimensional layouts (a single row or column) where content size drives the layout: navigation bars, toolbars, card rows, button groups, and centering. Use CSS Grid for two-dimensional layouts (rows and columns simultaneously) where the structure is more important than content size: page layouts, dashboards, photo galleries, and form layouts. They can be combined: Grid for overall page layout, Flexbox for component alignment. Choose based on whether you need one-dimensional or two-dimensional control.