Read a grid item’s start and end lines and predict where automatically placed siblings can fit.
The grid container determines the tracks. A child can ask to occupy a particular part of that grid, leaving the browser to place the other children in the remaining cells. Start by finding the edges of the space the child needs.
Read a three-column grid in horizontal, left-to-right text. The columns lie between lines 1 and 2, 2 and 3, and 3 and 4. For an item with grid-column set to 1 / 3, the first number is its starting edge and the second is its ending edge. It covers the first two columns, including the gap between them. The third column remains available.
span expresses how many tracks an item needs. A request to span two columns leaves the browser to find a suitable start if you do not supply one. An item that must reach a known boundary, such as a banner across the full explicit grid, is often easier to describe with edge lines. Line -1 identifies the last line of that explicit grid in the chosen axis.
Suppose the first item starts at row 1, column 1 and covers two columns. With default row-wise placement and single-cell siblings, the next item can take the third column of row 1. Its following sibling starts row 2. As more siblings arrive, Grid can create additional rows.
Visual placement can move a card away from its source-order neighbors. Keep the HTML sequence meaningful when someone reads the content or tabs between its controls.
Try it yourself
HTML + CSS