Skip to main content
D
CSS
CSS Grid Layout

CSS Grid Layout

CSS Grid builds complex two-dimensional layouts easily.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

CSS Grid creates exact rows and columns for advanced page structures. While Flexbox handles single rows, Grid manages the entire page layout at once. Developers can precisely place elements into specific cells or stretch them across multiple tracks.

Syntax

Syntax
1/* grid syntax */
2.grid {
3  display: grid;
4  grid-template-columns: 1fr 1fr;
5}

Example

Example
1/* this creates a simple grid */
2.container {
3  display: grid;
4  grid-template-columns: 200px auto;
5  gap: 15px;
6}

Key Points

  • The `display: grid` property activates the layout mode.
  • The `grid-template-columns` defines column widths.
  • The `grid-template-rows` defines row heights.
  • The `gap` property creates spacing between grid cells.

Up Next

Continue your journey with the next topic.

Go to CSS Responsive