freecoding.school100% FREE · NO SIGNUP
Grid CanyonISSUE #15 of 27

grid · the two-dimensional layout

FlexboVSThe Float Phantom
Flexbo saysCSS Grid lays out in two dimensions at once — rows and columns together.

Where flexbox is one axis, display:grid manages rows and columns simultaneously. You define a track template and place items into the resulting cells. Grid is the right tool for page layouts, card galleries, and any genuinely two-dimensional arrangement.

Power-ups you unlock

The Float Phantom attacks — common mistakes

Boss battleMake a 3-column grid of cards with display:grid and a gap.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.g{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.g div{background:#b388ff;color:#06040d;padding:18px;text-align:center}</style></head><body style="background:#06040d;padding:20px"><div class="g"><div>1</div><div>2</div><div>3</div></div></body></html>
▶ Open the interactive comic issue
‹ Flex Items · Align-Self · OrderGrid Container · Template-Columns · Template-Rows ›