DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

CSS Grid Areas: A Simple Way to Build Layouts

Describe CSS Grid layouts row by row with named areas, place elements using grid-area, and change the map for narrow screens.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CSS Grid areas let you describe a layout as named cells, one row at a time, then place elements into those regions with grid-area. Repeated names create larger rectangular regions; a period (.) marks an intentionally empty cell.

How CSS Grid areas work

Put grid-template-areas on a grid container. Each quoted string represents one row, and each whitespace-separated token in that string represents a cell. The MDN Web Docs definition is direct: “The grid-template-areas CSS property specifies named grid areas, establishing the cells in the grid and assigning them names.” MDN’s property reference documents the syntax and rules.

As an Amazon Associate I earn from qualifying purchases.

Names in the map define regions, but they do not automatically put child elements there. Give each child a matching grid-area value. A name repeated in adjacent cells makes one area spanning those cells.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build a compact page layout

This example lays out a header, navigation, main content, and footer. Its two columns are sized separately from the area map, and gap adds space between tracks.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
.page {
  display: grid;
  grid-template-columns: 12rem 1fr;
  grid-template-areas:
    "header header"
    "nav    main"
    ".      footer";
  gap: 1rem;
}

header { grid-area: header; }
nav    { grid-area: nav; }
main   { grid-area: main; }
footer { grid-area: footer; }
  • The first row assigns both cells to header, so the header spans two columns.
  • The second row places navigation beside the main content.
  • The period leaves the lower-left cell empty; the footer occupies the cell to its right.

Named areas establish placement, not track sizing. Use declarations such as grid-template-columns and grid-template-rows when you need to control column or row sizes. For a broader overview of grid tracks and placement, see MDN’s CSS grid layout guide.

Leave a blank space or span a region

Use a period as a null cell token when a cell should not belong to a named area. It is a placeholder in the map, not an area name, and not every cell needs a name.

To make an area span multiple cells, repeat its name in neighboring positions. The repeated cells must form a rectangle: a region can be one cell, a row or column of cells, or a larger rectangular block. A disconnected or L-shaped arrangement of the same name makes the grid-template-areas declaration invalid.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rearrange the layout at a breakpoint

You can replace the area map inside a media query while keeping the same elements and their grid-area assignments. For a narrow screen, this map stacks the header, main content, navigation, and footer:

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
@media (max-width: 40rem) {
  .page {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main"
      "nav"
      "footer";
  }
}

Here the map changes both the arrangement and the number of columns, so the one-column track definition accompanies the new one-cell-wide rows. MDN also illustrates redefining named areas at breakpoints in its grid template areas guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Named areas or line-based placement?

Named areas are an alternate way to place grid items and can be combined with line-based placement, as described in MDN’s grid-area reference. Choose according to the shape of the layout rather than treating one method as universally better.

Consideration Named areas Line-based placement
Communicating the intended layout A row-by-row map makes regions such as header, navigation, and main content visible in the CSS. Placement is expressed through grid line positions or spans rather than a named map.
Precise line or span control Useful when the design maps cleanly to named rectangular regions. Useful when placement needs explicit grid-line or span values.
Changing placement at breakpoints Redefine the map to show a different arrangement. Change the relevant line-based placement values.

A practical approach is to use named areas for the large regions whose relationships you want to read at a glance, and line-based placement where exact line or span control fits better.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check these details when a layout does not match the map

  • Confirm the parent has display: grid; the area map belongs on the grid container.
  • Check that each item’s grid-area value matches a name in the active map.
  • Count the cells in each row: every quoted row must describe the same number of columns.
  • Check repeated names for one connected rectangular shape; a missing or misplaced token can make a region invalid.
  • Set the needed columns and rows separately. Named areas do not decide their track sizes.
  • For responsive rules, make sure the map at the current viewport includes the regions the items are assigned to.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.