grid-template-rows
W3C CSS Snapshot 2026
Define the explicit rows. The values are in block-axis order.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
none | The initial value. This property declares no explicit tracks. |
120px / 25% | Sets a fixed length or a percentage of the relevant container size. A percentage can behave like auto when the size depends on its tracks. |
1fr / 2fr | Uses a fraction of the available space. A track with 2fr takes a twice-as-large share as 1fr when neither is limited by its minimum. |
auto / min-content / max-content | Sizes the track from its items. min-content uses their minimum intrinsic contribution and max-content uses their maximum intrinsic contribution. |
minmax(80px, 1fr) | Keeps the track at least 80px wide or tall and lets it share the remaining space. |
fit-content(180px) | Uses the content size with an upper limit of 180px when the automatic minimum allows it. |
repeat(3, 1fr) | Creates three tracks using the same size. auto-fit or auto-fill can repeat columns according to the available space. |
subgrid | Uses the parent grid’s tracks on this axis for a grid item that is itself a grid container. |
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-rows 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-columns: 1fr 1fr; grid-template-rows: 42px 76px; }
</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 A and B occupy the shorter first row. C occupies the taller second row.