Show Menu
Cheatography

A one-page CSS Grid quick reference designed for real-world use. This cheat sheet distills the most commonly used Grid properties, patterns, and alignment rules into a compact, printable format. Ideal for developers who already understand Grid and just need a fast reminder while building layouts.

Enable Grid

display: grid;
display: inline­-grid;

Grid Units

fr
Fraction of available space
px
Fixed size
%
Relative to grid container
auto
Size to content
min-co­ntent
Smallest possible
max-co­ntent
Largest possible
minmax(a, b)
Flexible range

Define Columns & Rows

grid-t­emp­lat­e-c­olumns: 200px 1fr 2fr;
grid-t­emp­lat­e-rows: auto 1fr auto;

Common Column/Row Patterns

repeat(3, 1fr)
repeat­(au­to-­fill, minmax­(250px, 1fr))
repeat­(au­to-fit, minmax­(250px, 1fr))

Common Layout Recipes

Equal Columns
grid-t­emp­lat­e-c­olumns: repeat(3, 1fr);
Responsive Cards
grid-t­emp­lat­e-c­olumns: repeat­(au­to-fit, minmax­(250px, 1fr));
Sticky Footer
grid-t­emp­lat­e-rows: auto 1fr auto;
 

Alignment

Align Tracks
justif­y-c­ontent: start | center | end | space-­between | space-­around | space-­evenly;
align-­con­tent: start | center | end | stretch;
Align Items
justif­y-i­tems: start | center | end | stretch;
align-­items: start | center | end | stretch;
Alignment (Indiv­idual Item)
justif­y-self: start | center | end | stretch;
align-­self: start | center | end | stretch;

Line Numbers & Keywords

grid-c­olumn: 1 / -1;
/* Full Width */
grid-row: auto;

Subgrid (When Supported)

grid-t­emp­lat­e-c­olumns: subgrid;
grid-t­emp­lat­e-rows: subgrid;
 

Named Grid Areas

.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.footer { grid-area: footer; }
grid-t­emp­lat­e-a­reas:
"­header header­"
"­sidebar main"
"­footer footer­";

Explicit Placement (Items)

grid-c­olumn: 1 / 3;
grid-row: 2 / 4;
grid-area: row-start / col-start / row-end / col-end;

Auto Placement

grid-a­uto­-flow: row;
grid-a­uto­-flow: column;
grid-a­uto­-flow: dense;
grid-a­uto­-rows: 200px;
grid-a­uto­-co­lumns: 1fr;

Debugging Tips

outline: 1px solid red;
on grid + items
grid-c­olumn: 1 / -1
is your “nuke it full width” button
If it is stretching weirdly, check
align-­items
first
If it is not wrapping, you probably want
auto-fit
or
auto-fill
Grid defines structure first. Items adapt.
   
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Five ways to center DIV element in CSS Cheat Sheet