DevTools Logo

CSS Grid Named Areas Builder

CSS Grid Named Areas Builder

Paint named areas on a grid and generate valid CSS Grid templates in your browser.

Grid editor

Choose an area name, then click cells to paint them. Use a dot for an empty cell.

Examples

Header over sidebar gap

Input
[["header", "header"], [".", "main"]]
Output
templateAreas: '"header header"\n  ". main"' + .header / .main grid-area rules

Dots stay literal placeholders in quoted rows, and each named area gets exactly one grid-area rule.

Smallest valid grid

Input
[["card"]]
Output
valid: true, templateAreas: '"card"', css with 1fr row/column plus .card rule

A 1x1 matrix is the minimum accepted grid and emits a single template row and rule.

About this tool

CSS Grid Named Areas Builder validates a string matrix with validateGridAreas(matrix): it rejects empty or ragged grids (Grid must contain at least one cell.), enforces CSS-identifier area names (Invalid area name ".."), and requires every named area to fill a solid rectangle — any L-shaped or disconnected footprint fails with Area "nav" must form a solid rectangle (L-shaped or disconnected areas are not allowed). "." cells and blank strings are empty placeholders, and areas returns first-seen names in order.

buildGridCss(matrix, rowSize = "1fr", columnSize = "1fr") emits the stylesheet regardless of validity: templateAreas quotes each row ("header header" / ". main", joined with \n plus two-space indent), the container sets display: grid with grid-template-areas, grid-template-rows (one rowSize per row), and grid-template-columns (one columnSize per column), then one .<name> { grid-area: <name>; } rule per area in first-seen order.

The minimum grid is a single cell: [["card"]] validates true with templateAreas '"card"' and one .card rule, and building is deterministic — the same matrix always yields the same templateAreas and css strings.

How to use this tool

  1. Lay out the matrix

    Provide rows of area names with "." for empty cells; validateGridAreas reports validity, message, and the ordered area list.

  2. Keep areas rectangular

    Fill each name's bounding box completely — L-shaped or split footprints are rejected with the solid-rectangle message.

  3. Copy the CSS

    Call buildGridCss(matrix) and paste .grid-container plus the per-area .<name> { grid-area: <name>; } rules into your stylesheet.

Use cases

Prototyping page shells

Sketch header/sidebar/main layouts as a name matrix and copy the grid-template-areas block into CSS.

Catching non-rectangular areas

Validate hand-drawn ASCII layouts and get the exact L-shaped area name to fix before writing CSS.

Teaching grid areas

Show how dots create gutters and how each quoted row maps to one grid-template row track.

Common mistakes

Mistake:Drawing L-shaped or split areas.

Fix:Every name must fill its full bounding rectangle — move the stray cell or rename it so each area is one solid block.

Mistake:Using invalid area names.

Fix:Names must match a CSS identifier (letters, digits, _/-; no leading digit) — rename "1st" to "first" and avoid spaces.

Mistake:Feeding ragged rows.

Fix:Every row needs the same column count; pad short rows with "." so the matrix is a true rectangle.

Frequently asked questions

What does this tool do?

It validates a name matrix with validateGridAreas and emits stylesheets with buildGridCss: quoted grid-template-areas rows, display: grid container with 1fr row/column tracks by default, and one .<name> { grid-area: <name>; } rule per area.

What passes validation, and what fails?

[["card"]] is the minimum valid 1x1 grid; [["header","header"],[".","main"]] keeps dot placeholders as '". main"'; and [["nav","nav"],["nav","."]] fails with Area "nav" must form a solid rectangle (L-shaped or disconnected areas are not allowed).

Is my layout uploaded or stored?

No. Validation and CSS emission are pure client-side string building — grid data never leaves your browser.

What does the CSS output contain?

A .grid-container with grid-template-areas (each row a quoted string), grid-template-rows/columns with one track per row/column, plus exactly one grid-area rule per named area in first-seen order.

References & standards

.env Secret Safety Linter

Validate .env syntax and spot likely leaked credentials or placeholder secrets.

.htaccess Generator

Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth

2D Fluid Dynamics & Particle Physics Sandbox

A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.

AI Function Calling Schema Generator

Generate function calling JSON schemas from TypeScript interfaces

Algorithm Arena & Data Structure Visualizer

Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.

Ansible Playbook Generator

Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML