Back to the blog
Development / DEVELOPMENT NOTES

Minesweeper with HTML, CSS, and JavaScript

A Windows XP-inspired clone, with a look at the flood fill that reveals empty regions of the board.

Browser-based Minesweeper board

This Minesweeper project takes its visual cues from the Windows XP classic. The board uses HTML elements and CSS, while JavaScript handles the game’s rules.

Browser-based Minesweeper board

Reveal an empty region

When a player clicks a cell with no neighbouring mines, the reveal should spread through connected empty cells. The numbered cells around that region are revealed too, without exposing the mines.

The operation can be expressed as a flood fill. I used an iterative traversal with a queue rather than a chain of recursive calls. This keeps the region’s depth from being limited by the call stack.

A board made of HTML elements

Leaving Canvas out makes it possible to inspect cells directly in the browser’s developer tools. The repository shows how each interaction connects to the game state.

Source code

Explore the project on GitHub

Written by Sergio Soriano

Development, curiosity, and shared projects.

About Sergio Soriano