Identify grid items, tracks, cells, and lines, and predict how items fill a simple grid.
In a wrapped flex layout, each line distributes its own space. A collection of cards sometimes needs the second card in every row to begin at the same horizontal position. Grid gives the entire collection a shared set of rows and columns.
The element with display: grid becomes the grid container. Its in-flow child elements become grid items. A heading inside one card belongs to the card’s internal layout. The card itself occupies a place in the collection.
A track is the space between two adjacent grid lines. It can be a column or a row. A cell is where one column and one row intersect. An item can occupy one cell or extend across several cells.
Follow a horizontal, left-to-right grid with three columns and two rows. It has six cells and four column lines. The left edge is line 1, the right edge is line 4, and the two interior boundaries are lines 2 and 3. A gap adds space between tracks without creating another track for an item.
If the grid has three columns and the items have no assigned positions or spans, the usual row-wise placement fills the first row in source order. The fourth item begins the second row under the first item. Longer text in one card can increase the height of its row while the column boundaries still line up across rows.
Try it yourself
HTML + CSS