Memory matching card game
Flip cards to find pairs, with 3D flip animations, a move counter, timer and difficulty levels.
Beginner⏱ 4–6 hours🪜 7 stepsHTMLCSSJavaScript
What you'll learn
- ◆Shuffling correctly (Fisher–Yates)
- ◆CSS 3D transforms
- ◆Managing game state and timing
What you'll build
- ✓4×4 and 6×6 grids
- ✓Smooth flip animation
- ✓Moves and timer
- ✓Best scores per level
Step-by-step guide
- 1
Card data
Pick symbols (emoji or images), duplicate them for pairs, shuffle with Fisher–Yates.
- 2
Render grid
CSS grid of buttons; each card has a front and back face.
- 3
Flip animation
transform: rotateY(180deg) with transform-style: preserve-3d and backface-visibility: hidden.
- 4
Game logic
Allow two open cards; if they match keep them, else flip back after 800 ms; lock clicks during that time.
- 5
Stats
Count moves; start the timer on the first flip; stop when all pairs are found.
- 6
Win screen
Show moves and time; save best results in localStorage per difficulty.
- 7
Accessibility
Cards are buttons with aria-labels; keyboard works.
🚀 Make it stand out
- +Themes (flags, programming logos you made yourself)
- +Two-player turns
- +Daily puzzle with a fixed seed