CSS gridtemplateareas Property (original) (raw)

CSS grid-template-areas Property

Last Updated : 27 Aug, 2024

The _grid-template-areas property in CSS allows you to define named _grid areas within a _grid layout. This property specifies how grid items are placed into areas using a named grid template. Let's explore its syntax, values, examples, and browser support.

**Syntax

grid-template-areas: none | 'name1 name2 ...' | 'name3 name4 ...';

Property Value

**Example 1: This example displays the grid-template-areas property.

html `

CSS grid-template-areas Property
<style>
    .GFG1 {
        grid-area: area;
    }

    .geeks {
        background-color: green;
        padding: 30px;
        display: grid;
        grid-template-areas: 'area area';
        grid-gap: 20px;
    }

    .GFG {
        background-color: white;
        font-size: 30px;
        text-align: center;
    }
</style>
A
B
C
D
E
F
G
H

`

**Output: CSS grid-template-areas-example1 **Example 2: This example displays the grid-template-areas property.

html `

CSS grid-template-areas Property
<style>
    .GFG1 {
        grid-area: area;
    }

    .geeks {
        background-color: green;
        padding: 30px;
        display: grid;
        grid-template-areas:
            'area area . . .'
            'area area . . .';
        grid-gap: 20px;
    }

    .GFG {
        background-color: white;
        font-size: 30px;
        text-align: center;
    }
</style>
A
B
C
D
E
F
G

`

**Output:

CSS grid-template-areas-example2Understanding how to utilize the grid-template-areas property effectively can enhance the organization and structure of your CSS grid layouts, improving readability and maintainability of your code.

**Supported Browsers: The browser supported by _grid-template-areas property are listed below: