Grid Template Areas Named Layout

Create a named grid layout using template areas for an app shell with header, sidebar, main, and footer regions.

CssData Integrity

Code

csssnippet
16 lines
.app-shell {
  display: grid;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  gap: 1rem;
}

.app-header { grid-area: header; }
.app-sidebar { grid-area: sidebar; }
.app-main { grid-area: main; }
.app-footer { grid-area: footer; }

How the snippet works

display: grid owns the layout: tracks are declared on the container, so children fall into place without wrapper markup.

gap spaces grid/flex items without margins on the children.

grid-template-columns declares the column tracks the children flow into.

The rules target .app-shell, .app-sidebar, .app-main, .app-footer — each selector names the element it restyles, in source order.

Interactive Tools for This Topic

FAQ

Which elements does this stylesheet target?
The rules bind to `.app-shell`, `.app-sidebar`, `.app-main`, `.app-footer`; when two rules tie in specificity, the one written later in the file wins.