CSS grid-template Property
Description
The grid-template property is the shorthand used to define a grid container’s explicit structure: it bundles the declaration of track sizes and the layout of named areas into a single, high-level instruction that determines the rows, columns and area topology the container will present to its children. By setting the explicit row and column tracks and any named areas together, it establishes the coordinate system — named lines, area names and track order — that grid items refer to when they are positioned. This makes the property a convenient way to express complete grid blueprints without writing separate declarations for each part.
When you use grid-template you are effectively producing the same conceptual outcome as separately defining the rows, the columns and the named areas; those component properties are grid-template-rows, grid-template-columns and grid-template-areas. The named lines and areas created by this explicit grid become reference points for placement: individual child placement properties such as grid-row and grid-column (or area-based placement) map items onto those tracks and areas. Because it defines the explicit grid, grid-template also affects how gaps and track boundaries are interpreted when sizing and aligning items inside the container.
The explicit grid produced by grid-template interacts with the grid’s implicit behavior. If items are placed outside the explicit tracks you declared, the formatting system will create implicit tracks to accommodate them; those implicit tracks are governed by properties such as grid-auto-rows and grid-auto-columns, and the way items are flowed into the grid is influenced by grid-auto-flow. In practice this means you can design a rigid explicit structure for most content and still allow overflow or additional items to be handled predictably by the implicit-track rules.
In real-world layouts, grid-template is useful when you want a single, readable declaration that represents the whole grid plan — especially for complex templates that use named areas or multiple named grid lines. For simpler or highly dynamic needs, authors sometimes prefer to set only the rows or columns or to rely on automatic placement, but using the shorthand keeps the relationship between tracks and areas explicit and centralized. It is also worth noting how this shorthand relates to the broader grid shorthand grid, which can combine placement algorithm and template definitions; choosing between them is largely a matter of whether you want to express placement/flow behavior together with the template or keep the template definition isolated.
Definition
- Initial value
- See individual properties
- Applies to
- Grid containers
- Inherited
- No
- Computed value
- See individual properties
- Animatable
- Yes
- JavaScript syntax
- object.style.gridTemplate
Interactive Demo
Syntax
grid-template: none | [ <grid-template-rows> / <grid-template-columns> ] | [ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <explicit-track-list> ]? where <line-names> = '[' <custom-ident>* ']' <track-size> = <track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( [ <length> | <percentage> ] ) <explicit-track-list> = [ <line-names>? <track-size> ]+ <line-names>? where <track-breadth> = <length-percentage> | <flex> | min-content | max-content | auto <inflexible-breadth> = <length> | <percentage> | min-content | max-content | auto where <length-percentage> = <length> | <percentage>
Values
- noneIs a keyword that sets all three longhand properties to none, meaning there is no explicit grid. There are no named grid areas. Rows and columns will be implicitly generated; their size will be determined by the grid-auto-rows and grid-auto-columnsproperties.
- <grid-template-rows> / <grid-template-columns>Sets grid-template-rows and grid-template-columns to the specified values, and sets grid-template-areas to none.
- [ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <explicit-track-list> ]?Sets grid-template-areas to the strings listed, grid-template-rows to the track sizes following each string (filling in auto for any missing sizes), and splicing in the named lines defined before/after each size, and grid-template-columns to the track listing specified after the slash (or none, if not specified).
Example
Browser Support
The following information will show you the current browser support for the CSS grid-template property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
