Why is this an issue?

The grid-template-areas property, as well as the grid-template and grid shorthands, define a grid layout with quoted strings. Each string represents a row. Each cell is either a name or a run of periods (.), which represents an unnamed cell, and cells are usually separated by whitespace. A named area that covers multiple cells must form a filled-in rectangle.

If a string is empty (""), rows have different numbers of cells, or a named area does not form a rectangle, the grid-template-areas declaration is invalid. The browser ignores that declaration, so the layout can differ from what the stylesheet suggests.

Give every row the same number of cells, include at least one cell in each row, and arrange repeated area names in a rectangle. This rule reports empty strings, unequal row widths, and some non-rectangular named areas. It does not detect every invalid arrangement of named areas.

Code examples

Noncompliant code example

.page {
  grid-template-areas:
    "header header"
    "main sidebar footer"; /* Noncompliant: this row has three cells instead of two */
}

Compliant solution

.page {
  grid-template-areas:
    "header header"
    "main sidebar";
}

Noncompliant code example

.page {
  grid-template-areas:
    "header header"
    ""; /* Noncompliant: this row has no cells */
}

Compliant solution

.page {
  grid-template-areas:
    "header header"
    "main sidebar";
}

Noncompliant code example

.page {
  grid-template-areas:
    "main main" /* Noncompliant: the "main" area is not a rectangle */
    "main sidebar";
}

Compliant solution

.page {
  grid-template-areas:
    "main main"
    "sidebar sidebar";
}

Resources

Documentation