2018-09-30 23:01:58 +01:00
---
id: 5a94fe0569fb03452672e45c
title: Divide the Grid Into an Area Template
challengeType: 0
2019-08-05 09:17:33 -07:00
forumTopicId: 301130
2021-01-13 03:31:00 +01:00
dashedName: divide-the-grid-into-an-area-template
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
You can group cells of your grid together into an < dfn > area</ dfn > and give the area a custom name. Do this by using `grid-template-areas` on the container like this:
2019-05-14 01:11:58 -07:00
```css
grid-template-areas:
"header header header"
"advert content content"
2021-08-05 23:52:00 -05:00
"advert footer footer";
2019-05-14 01:11:58 -07:00
```
2021-08-05 23:52:00 -05:00
The code above groups the cells of the grid into four areas; `header` , `advert` , `content` , and `footer` . Every word represents a cell and every pair of quotation marks represent a row.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --instructions--
2018-09-30 23:01:58 +01:00
2021-08-05 23:52:00 -05:00
Change the template so the `footer` area spans the entire bottom row. Defining the areas won't have any visual effect right now. Later, you will make an item use an area to see how it works.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2021-08-05 23:52:00 -05:00
`container` class should have a `grid-template-areas` property similar to the example but with the `footer` area spanning the whole bottom row.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(
__helpers
.removeCssComments(code)
.match(
2021-08-05 23:52:00 -05:00
/.container\s*?{[\s\S]*grid-template-areas\s*?:\s*?"\s*?header\s*?header\s*?header\s*?"\s*?"\s*?advert\s*?content\s*?content\s*?"\s*?"\s*?footer\s*?footer\s*?footer\s*?"\s*?;[\s\S]*}/gi
2020-11-27 19:02:05 +01:00
)
);
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
```html
< style >
.item1{background:LightSkyBlue;}
.item2{background:LightSalmon;}
.item3{background:PaleTurquoise;}
.item4{background:LightPink;}
.item5{background:PaleGreen;}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
.container {
font-size: 40px;
min-height: 300px;
width: 100%;
background: LightGray;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-gap: 10px;
grid-template-areas:
2020-02-27 07:20:46 -08:00
/* Only change code below this line */
2018-09-30 23:01:58 +01:00
"header header header"
"advert content content"
2021-08-05 23:52:00 -05:00
"advert footer footer";
2020-02-27 07:20:46 -08:00
/* Only change code above this line */
2018-09-30 23:01:58 +01:00
}
< / style >
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
< div class = "container" >
< div class = "item1" > 1< / div >
< div class = "item2" > 2< / div >
< div class = "item3" > 3< / div >
< div class = "item4" > 4< / div >
< div class = "item5" > 5< / div >
< / div >
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
2018-10-23 16:21:53 +03:00
```html
< style >
.item1{background:LightSkyBlue;}
.item2{background:LightSalmon;}
.item3{background:PaleTurquoise;}
.item4{background:LightPink;}
.item5{background:PaleGreen;}
.container {
font-size: 40px;
min-height: 300px;
width: 100%;
background: LightGray;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-gap: 10px;
grid-template-areas:
"header header header"
2021-08-05 23:52:00 -05:00
"advert content content"
2018-10-23 16:21:53 +03:00
"footer footer footer";
}
< / style >
2018-09-30 23:01:58 +01:00
2018-10-23 16:21:53 +03:00
< div class = "container" >
< div class = "item1" > 1< / div >
< div class = "item2" > 2< / div >
< div class = "item3" > 3< / div >
< div class = "item4" > 4< / div >
< div class = "item5" > 5< / div >
< / div >
2018-09-30 23:01:58 +01:00
```