thecodezone.
The Code Zone
Developer Playbook / Project workshops

FREE PLAYBOOK WORKSHOP / HTML & CSS

Six faces.
One working dice roller.

Build a CSS Dice Roller

Start with one dot. Copy your die, change its pattern, then roll it. Practice HTML structure, CSS Grid and reusable classes while keeping all six faces visible.

16 alternating HTML/CSS steps · About 60–90 minutes · No installation needed

The whole workshop is free. Your code and checkpoints save in this browser when signed out. Sign in with your Code Zone learning account to save across devices and keep your work on your profile.

Cartoon Rob explains one center dot on a three-by-three grid, compares two- and three-dot dice, then helps a learner roll a six.
A grid gives each dot a predictable home. Reuse those positions to build six different faces, then try the supplied rolling behavior.

WATCH THE FREE INTRODUCTION

See what you will build.

A quick tour of the finished roller, the skills you will practice and how the workshop works. No sign-in needed.

GRID INSIDE / FLEXBOX OUTSIDE

Give every dot a place.

Each die has three equal rows and three equal columns. Position classes such as top-left and center tell CSS which cell a dot belongs in. The same classes work across every die.

Flexbox wraps the gallery cards onto new rows as the screen gets smaller. You will compare phone and desktop previews without squeezing the dice.

Copy, change, style.

  1. Build your first face below its supplied comment.
  2. Copy the previous face’s entire section below the next face comment.
  3. Change the copied id and heading, then adjust its dots.
  4. Switch to CSS and follow that step’s checklist.
  5. Keep all earlier faces to compare your progress.

TRY THE FINISHED EXAMPLE

A roller you can use.

Scroll inside the example to find Roll the Dice below the six faces. The supplied JavaScript copies one of your faces and announces its number. You build the HTML and CSS; the JavaScript is hidden from the workshop editor and included in the optional CodePen export.

YOUR PATH THROUGH THE WORKSHOP

HTML, then CSS. Repeat.

  1. 01
    HTMLName your dice gallery
  2. 02
    CSSGive the page breathing room
  3. 03
    HTMLBuild face one
  4. 04
    CSSMake the die a three-by-three grid
  5. 05
    HTMLCopy face 1 to build face 2
  6. 06
    CSSPlace the diagonal dots
  7. 07
    HTMLCopy face 2 to build face 3
  8. 08
    CSSGive each face a readable card
  9. 09
    HTMLCopy face 3 to build face 4
  10. 10
    CSSPlace the other two corners
  11. 11
    HTMLCopy face 4 to build face 5
  12. 12
    CSSLet the gallery wrap onto new rows
  13. 13
    HTMLCopy face 5 to build face 6
  14. 14
    CSSFinish both columns of three
  15. 15
    HTMLAdd the working roll controls
  16. 16
    CSSStyle and try your dice roller

After all 16 checks pass, step 17 opens Export to CodePen. Exporting is optional and does not affect your completion.

OPTIONAL FINISHING CHALLENGE / NOT GRADED

Give your dice a theme.

After finishing the guided steps, design your own dice set. This is a separate design challenge, not another required checkpoint.

  • Choose a new die and dot color pair with clear contrast.
  • Keep all six dot counts and positions correct.
  • Check the gallery at phone and desktop widths.
  • Roll with the mouse and with Tab and Enter. Keep the result readable and keyboard focus visible.
  • Explain which rules style all dice and which rules place individual dots.

Your earned checkpoints remain saved. The original checks still expect the workshop’s requested values. Your later CodePen edits are separate from your Code Zone work.