vasilenko.info

CSS Grid builder

/en/tool/css-grid-builder/ works calculated by the browser

Set the columns, rows, and gaps, then drag across the cells to create a named area. The output includes grid-template-areas, alignment, and markup to apply it all to.

promoTwenty years of notes on websitesHow we did it in 2008 and what still works today.Open

Grid builder

Lines are numbered from one, and the last line is one higher than the number of tracks — numbers are shown along the edges of the preview.

Ready-made layouts

The preset sets both tracks and named areas — customize them as needed.

Grid size
4
3
16 px
16 px
720 px The preview is rendered at exactly this width. If it is wider than the panel, the preview scrolls horizontally — so you can see how the grid breaks on a narrow screen.
Responsive grid
240 px
9

While the responsive grid is enabled, the number of columns, custom tracks, and areas are disabled: the browser controls the layout, so there is nothing to draw cell by cell.

Column width
Row height
Align the entire grid

Default values are not added to the code: CSS includes only the values you changed. justify-content and align-content become visible when the tracks do not fill the container — for example, when all columns are 120px.

Areas

Drag across the preview cells to create an area. With the keyboard: press Enter on the first cell, then on the second. You can drag a completed area, resize it from the corner, or delete it with the Delete key.

Cyrillic is transliterated into Latin: «шапка» becomes shapka. Leave it empty to generate a name automatically.

    Narrow screen
    640 px
    1

    Areas in the media query stack vertically in order — a common mobile layout pattern.

    Ctrl + Z undoes, Ctrl + Shift + Z redoes. The last grid is saved in the browser and reopens when you return to the page.

    Preview

    Columns and rows
    Last column line
    Column width at 1fr
    Areas
    grid-template-areas

    Output format

    grid.css Grid styles
    index.html Markup for these styles

    Calculated by the browser. The preview is a real grid with the same properties as the generated code; after loading, the page makes no requests. Settings are stored in the URL after the hash — you can share the link.

    promoCalculate ROI at the same timeCampaign payback based on spend and revenue.Open

    How to use it

    1. Use a ready-made layout or start with the number of columns and the gap. When laying out a grid, rows are usually left at auto: their height is determined by the content.

    2. Drag across the preview cells to create an area. Enter its name before drawing or rename it afterward: names go into grid-template-areas, making the layout readable without counting lines.

    3. You can drag a finished area to move it, resize it using the handle in the lower-right corner, and delete it with the Delete key. Click to select; use the arrow keys to move it; use Shift with the arrow keys to resize it.

    4. The container width applies to the preview itself. Move the slider from 320 to 1440 to see where the layout stops fitting; the «Narrow screen» checkbox adds a media query for that width.

    5. The «Responsive grid» switch applies repeat(auto-fit, minmax(N, 1fr)) — a layout without media queries, where the browser calculates the number of columns.

    6. Switch the output format on the right: CSS, SCSS, Tailwind, a style object for JSX, or styled-components. The corresponding markup is always shown next to the style code.

    promoBrowser task listNo account required—everything is stored on your device.Open

    The formula and what it includes

    Column width at 1fr = (container width − gaps) ÷ number of columns

    fr divides only the available space. If the grid contains a 200px track, the browser first subtracts it and all gaps from the container width, then divides the remainder among the fr tracks.

    Example breakdown: header, sidebar, content, and footer

    The input data is the same as the default field values: you can calculate it mentally and confirm that the tool is telling the truth.

    1. There are three gaps between four columns: 3 × 16 = 48 px. That leaves 720 − 48 = 672 px for the tracks, or 168 px per track.

    2. The header spans the entire first row — columns 1 through 4. These are lines 1 through 5, so grid-column: 1 / 5.

    3. The sidebar is the first column of the second row, and the content spans columns 2 through 4 of the same row. The footer again spans the full width.

    4. All four areas are named, so a map is generated instead of line numbers: "shapka shapka shapka shapka" / "sidebar kontent kontent kontent" / "podval podval podval podval".

    5. Each block only needs one line: .sidebar { grid-area: sidebar; } — there is no need to count line numbers anymore.

    grid-template-areas with three rows, plus one grid-area declaration per block — and the HTML markup it applies to, shown alongside.

    Frequently asked questions

    promoAll toolsForty-four tools, all running in your browser.Open

    Related tools

    5