CSS Grid

What is it?

CSS Grid is a two-dimensional layout system that allows you to create complex grid-based layouts with rows and columns simultaneously. Unlike Flexbox which works in one direction at a time, Grid lets you control both horizontal and vertical placement of elements, making it ideal for overall page layouts, image galleries, and complex component arrangements.

Practical example

To create a responsive portfolio gallery, you use display: grid with grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) to automatically create columns that are at least 300px wide but grow to fill available space. Add gap: 20px for consistent spacing between items, and the layout automatically adjusts to different screen sizes without media queries.

Test your knowledge

What CSS property enables Grid layout?

Ask Lex
Lex knows the context of this term and can give targeted explanations, examples, and extra context.
Tip: Lex replies briefly in the widget. For more detail, go to full screen mode.

Learn our language

Learn these terms from real professionals and take your skills further at KdG MCT.

Study at KdG