0Pricing
CSS Academy · Lesson

Display Grid and Template Columns Rows

Enable CSS Grid and define column and row tracks using grid-template-columns and rows.

Enabling CSS Grid

CSS Grid is activated with display: grid on a container. Its direct children become grid items automatically placed into cells.

.layout {
  display: grid;
}

grid-template-columns

grid-template-columns defines the number and size of columns. Each value creates one column track.

.layout {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  /* 3 columns: 200px fixed, two equal flexible columns */
}

All lessons in this course

  1. Display Grid and Template Columns Rows
  2. The fr Unit and Repeat
  3. Gap and Grid Placement
  4. Grid Template Areas
← Back to CSS Academy