CSS grid-template Property
Example
.grid-container {
display: grid;
grid-template: 150px / auto auto auto;
}
1
2
3
4
5
6
Meaning
The grid-template property is a shorthand property for defining grid columns, rows, and areas.
Default value: | none none none |
Inherited: | No |
Animatable: | Yes |
Version: | CSS Grid Layout Module Level 1 |
JavaScript syntax: |
|
Standard Syntax
grid-template: none|grid-template-rows / grid-template-columns|grid-template-areas|initial|inherit|revert|revert-layer|unset;
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Status
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
none | This is default value. No specific sizing of the columns or rows. |
grid-template-rows / grid-template-columns | Specifies that the size(s) of the columns and rows. |
grid-template-areas | Specifies that the grid layout using named items. |
initial | Sets this property to its default value. |
inherit | If specified, the associated element takes the computed value of its parent element animation-delay property. |
revert | Reverts the cascaded value of the property from its current value to the value the property |
revert-layer | Rollback styles to the ones specified in previous cascade layers. |
unset | Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not. |
Default CSS Property Values
selectors {
grid-template: none none none;
}
More Example
Example
.grid-container {
display: grid;
border: 2px dashed #ddd;
padding: 10px;
grid-gap: 10px;
grid-template: auto 1fr / auto 1fr;
}
The following example show how to use grid areas:
Example
.grid-container {
grid-template:
"header header header header header header"
"nav nav nav nav nav nav"
"column1 column1 column2 column2 column3 column3"
"footer footer footer footer footer footer";
}