Explicit tracks are the rows and columns declared directly with grid-template-columns or grid-template-rows. They establish the grid’s planned structure before item placement, giving Grid known lines and track sizes to work from. section 4.3
This distinction matters when a layout grows. Tracks created because an item is placed beyond the declared grid, or because Grid needs room for more items, are implicit. The sizing algorithm first identifies both kinds, then resolves intrinsic sizes, content constraints, and any remaining fr space. section 4.3
Create tracks explicitly when the layout needs dependable structure:
- Define known columns or rows with grid-template-columns and grid-template-rows. section 4.3
- Use negative line numbers such as -1 to place an item relative to the grid’s end; negative numbering exists only for explicit tracks. section 4.2.3
- Declare rows instead of relying on grid-auto-rows when an item must occupy the final row with grid-row: -2 / -1. section 4.5
A full-width title that survives column changes
For a title or caption spanning a table-like grid, use grid-column: 1 / -1. Line 1 starts the explicit grid and -1 selects its final line, so the item continues to span every declared column even when the column count changes. section 4.2.3
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 200px 200px 200px 100px;
}
Declaring four rows makes their ending lines explicit, allowing a footer or total row to target the last row with negative grid lines. section 4.5
Explicit tracks also make sizing easier to reason about. Fixed sizes, intrinsic keywords, minmax(), and fr units are resolved as part of the track-sizing process; fr space is distributed only after fixed tracks, gaps, padding, and borders are accounted for. section 4.3 section 4.5
Practical takeaway: declare the grid structure whenever placement depends on stable line references. Let Grid add implicit tracks for overflow or automatic placement, but do not expect those tracks to support negative indices. section 4.2.3 section 4.6
