How can I place a grid item across several columns?
Quick answer
The question, the details, the next step.
A practical checklist
Confirm the grid container has the intended column tracks.
Choose the spanning item and identify its starting grid line.
Set
grid-columnwith aspancount for the number of tracks to cover.Check other explicit placements for unintended overlap.
Inspect where unplaced items land and whether spans leave holes.
A few more useful answers
Can I specify the ending grid line instead of using `span`?
Yes. Grid placement can use a start and end grid line, or a span count. For example, grid-column: 1 / 3 specifies lines 1 and 3; grid-column: 1 / span 2 specifies a start and the number of tracks to span. [S1]
Will the other items always fill every open spot?
No. Auto-placement puts items into available space under its placement rules, but spanning items can leave holes when later items do not fit. [S2]
Could explicitly positioning another card cause a collision?
It could: explicit placements can overlap. Check the placement of each explicitly positioned item against the others. [S1]
Sources
References used for this guide.
- [S1] Grid layout using line-based placement developer.mozilla.org · Checked
- [S2] Auto-placement in grid layout developer.mozilla.org · Checked
