Course contentsShow
← Web Development
Lesson 316 of 2,9826. CSS GridFree lesson

Basic Two-Column Grid with grid-template-columns

Creating your first simple grid by defining column tracks with explicit sizes.

Basic Two-Column Grid with grid-template-columns

You'll learn how to create your first simple two-column grid layout by explicitly defining column widths.

Now that you understand what CSS Grid is and how to enable it with display: grid, it's time to actually define columns. By default, a grid container creates a single column. To create multiple columns, you use the grid-template-columns property.

The Core Concept

Think of grid-template-columns as drawing vertical lines to divide your grid into columns. Each value you provide defines the width of one column track. Want two columns? Provide two values. Want three? Provide three values.

The property is applied to the grid container (not individual items), and it establishes the explicit grid structure.

Basic Syntax

.container {
  display: grid;
  grid-template-columns: 200px 400px;
}

This creates a two-column grid:

  • First column: 200px wide
  • Second column: 400px wide

Simple Example

.grid-container {
  display: grid;
  grid-template-columns: 300px 300px;
}
<div class="grid-container">
  <div>Column 1</div>
  <div>Column 2</div>
  <div>Column 3</div>
  <div>Column 4</div>
</div>

The first two items occupy the two columns in row 1. The next two items automatically flow into row 2, creating an implicit second row.

Different Column Widths

Columns don't need to be equal:

.container {
  display: grid;
  grid-template-columns: 150px 450px;
}

This creates a narrow sidebar (150px) and a wide main content area (450px).

Key Takeaway: grid-template-columns defines the width of each column track in your grid by listing space-separated values—each value creates one column.