SyntaxStudy
Sign Up
CSS CSS Grid Introduction
CSS Beginner 1 min read

CSS Grid Introduction

CSS Grid

CSS Grid is a two-dimensional layout system — it handles both rows and columns simultaneously. Use Grid for page-level layouts, Flexbox for component-level layouts.

Enabling Grid

Set display: grid on the container. Then define columns and rows.

Grid vs Flexbox

GridFlexbox
2D (rows + cols)1D (one direction)
Layout-firstContent-first
Page/section layoutsComponent alignment
Example
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;  /* 3 equal columns */
  gap: 16px;
}

/* Items fill cells automatically */
.item { background: #6366f1; padding: 24px; }