CSS generator guides

Build a page shell with four named CSS Grid areas

·

Named grid areas make placement readable in a stylesheet. The Page shell example lets you compare the dimensions of each area with its track and gap values before applying it to a real page.

CSS Grid Generator

Check the 96-pixel sidebar and expanding main area

Load Page shell and keep Preview width at 480 pixels. The first column is 96 pixels wide, the column gap is 12 pixels and the main area gets the remaining 372 pixels. The masthead and footer occupy both columns.

Reduce Preview width to 360 pixels. The sidebar stays 96 pixels wide and the main area becomes 252 pixels wide. The flexible second track absorbs the 120-pixel change.

W3C CSS Grid, explicit track sizesW3C CSS Grid, named areas

Correct a named area that contains a notch

In Named areas, replace the middle row sidebar main with masthead main. The masthead now occupies three cells in an L shape and the export shows an error.

Restore sidebar main so each area is rectangular. Export grid-layout.css and grid-layout.html. The grid-area declarations for masthead, sidebar, main and footer match classes on the generated children.

W3C CSS Grid, named areasW3C CSS Grid, grid placement

Compare with a grid of responsive cards

Load Responsive cards to clear the named areas and try repeat(auto-fit, minmax(136px, 1fr)). Keep the column gap at 12 pixels. Three columns need 432 pixels, so a width of 460 shows three columns and a width of 420 shows two.

Use this pattern for items that can flow into a changing number of columns. Use a named matrix for placements tied to a specific row and column count.

W3C CSS Grid, automatic track repetitionW3C CSS Grid, explicit track sizes

Common questions

Can the preview use automatic repeat with a named matrix?

Use a numeric repeat count with named areas in this tool. Its matrix needs a known number of cells in each dimension.

Why is the empty cell marked with a dot?

A dot leaves the cell unnamed. Other entries identify the grid areas assigned to named children.

Sources

Put it into practice.

Related guides