CSS Grid
CSS Grid is a two-dimensional CSS layout system for arranging content into rows and columns at the same time. You enable it with display: grid on a container.
Web
Grid is ideal for full page layouts and complex component arrangements where you need to control both rows and columns. Flexbox handles one dimension; Grid handles two.
You define the structure with properties like grid-template-columns and grid-template-rows, and the gap property adds space between cells.
Examples
CSS
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
}Output:
Arranges children into three equal-width columns with 12px gaps between items.Learn it in a lesson
- CSS Grid →