grid-template

W3C CSS Snapshot 2026

Set the explicit rows, columns, and optionally named areas in one declaration.

On this page

Syntax and values

Value or syntaxWhat it does
noneClears all three explicit template properties.
40px 70px / 1fr 2frRows go before the slash and columns go after it.
"head head" 40px "side main" 70px / 1fr 2frCombines an area map with row heights and column widths.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>grid-template example</title>
  <style>
.layout { display: grid; width: min(100%, 320px); border: 2px solid teal; box-sizing: border-box; }
.layout > div { padding: 8px 12px; background: #def5f5; color: #123; border: 1px solid #81b9b5; box-sizing: border-box; }
.layout { grid-template: 40px 70px / 1fr 2fr; }
  </style>
</head>
<body>
<div class="layout">
  <div class="first">A</div>
  <div class="second">B</div>
  <div>C</div>
</div>
</body>
</html>

What to expect The second row is taller and the second column is wider.

Official references