Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS grid-template-areas property

CSS grid-template-areas property

Example

The following example names item1 "myArea" and spans five columns:

.item1

{

grid-area:

myArea

;

}

.grid-container

{

grid-template-areas:

'

myArea

myArea

myArea

myArea

myArea

'

;

}

Try it »


Browser support

The numbers in the table indicate the first browser version that supports this property.

property
grid-template-areas 57 16 52 10 44

Property definition and usage

The grid-template-areas property is used to set up a grid layout.

The grid-area property can be used to name grid items.

Named grid items can be referenced through the container's grid-template-areas property.

Each row is defined within single quotes ' ', separated by spaces.

A . indicates a grid item with no name.

Default value: auto
Inherited: no
Animatable: support. Read about animatable Try it
Version: CSS Grid Layout Module Level 1
JavaScript syntax: object.style.gridTemplateAreas=". . . myArea myArea" Try it

Syntax

grid-template-areas: none|itemnames;

Value Description
none Default value; no named grid is referenced.
* itemnames * Specifies how each column and row should be displayed.

More examples

.

A dot indicates an unnamed grid item.

Example

.item1

{

grid-area:

myArea

;

}

.grid-container

{

grid-template-areas:

'

myArea

myArea

. . .'

;

}

Try it »

The following example sets "item1" to span 2 rows and 2 columns:

Example

.item1

{

grid-area:

myArea

;

}

.grid-container

{

grid-template-areas:

'

myArea

myArea

. . .'

;

}

Try it »

Name all grid items and create a web page template:

Example

.item1

{

grid-area:

header

;

}

.item2

{

grid-area:

menu

;

}

.item3

{

grid-area:

main

;

}

.item4

{

grid-area:

right

;

}

.item5

{

grid-area:

footer

;

}

.grid-container

{

grid-template-areas:

'

header

header

header

header

header

header

' '

menu

main

main

main

right

right

' '

menu

footer

footer

footer

footer

footer

'

;

}

Try it »


Related Articles

CSS Tutorial: CSS Grid Layout

CSS Reference Manual: grid-area property

CSS Reference Manual: grid-template property