Skip to content

CSS Grid

In one line

CSS Grid is a layout module for creating two-dimensional grids with rows and columns.

In simple words

CSS Grid is a layout system that lets you arrange elements in both rows and columns simultaneously. Unlike Flexbox (which is one-dimensional), Grid excels at complex page layouts where you need precise control over both axes.

To use Grid, set display: grid on a container and define columns and rows with grid-template-columns and grid-template-rows. You can place items in specific cells, span them across multiple cells, and create responsive layouts with the fr (fraction) unit.

Grid is ideal for full page layouts, photo galleries, dashboards, and any design that needs a structured grid. Modern CSS development often combines Grid for page-level layout with Flexbox for component-level layout.

Example

css
.grid {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 1rem;
}
/* 3 columns: the middle one is twice as wide */

A 3-column grid where the middle column is double the width of the side columns.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary