We may take CSS for granted, but it’s incredible to think about just how powerful it has become. What started as a simple way to style various design elements has evolved into so much more. We now use the language to handle tasks such as layouts and animation with ease – and without a second thought.
Among the best examples of this trend are the bevy of pure CSS games that are popping up. They’re fun to play and give us a hint at what can be achieved with a bit of creativity.
Here’s a look at some of the best pure CSS games on CodePen. They range from the stupefyingly simple all the way to “wow, CSS can do that?” – enjoy!
Rock, Paper, Scissors by Jerry Low
A rock, paper, scissors session is always a great way to beat boredom. If you don’t have a partner to play along with, you can give this virtual version a go.
Click on your weapon of choice and then on the “Fight!” button to see how you did. The game uses HTML radio buttons and some random CSS to power the match.
See the Pen Pure CSS Game Rock Paper Scissor by Jerry Low
Minesweeper for Git Commits by Stephanie Eckles
This game combines the classic premise of Minesweeper with the look of a GitHub contribution graph.
See how many squares you can paint before hitting one of those pesky mines. Again, CSS is used to generate “random” locations for each mine.
See the Pen CommitSweeper – Pure CSS Game by Stephanie Eckles
Save the World from Demons by Mark Sottek
Here’s a simple shooter game that asks you to take out some demonic minions (no, not those minions).
Place your cursor over a demon and click to send them packing. A quick look under the hood reveals that HTML checkboxes and animated GIFs make the whole thing work.
See the Pen Demon Killer II by Mark Sottek
You Want Cake? You’d Better Earn It by Jhey
Sure, everybody wants some cake. But this game may drive you mad in its pursuit, as it takes some skill with your mouse.
Hover over a tiny box and avoid the little crumbs and sprinkles. If you make it through, you shall be rewarded. Move your cursor too far, though, and you’ll have to start all over again.
See the Pen Pure CSS Cake 100×50 Game 🎂🎉 by Jhey
Guess the Movie Inès
This little trivia/hangman-style game makes clever use of the CSS
:invalid pseudo-classes to guide you towards a correct answer.
First, you’re shown a set of emojis that represents a movie. From there, you’re expected to type in the movie’s name. But each form input only has a single valid letter. CSS will tell you if you’ve entered the right one (or you could just look at the source code).
See the Pen Guess The Movie – a mini CSS game by Inès
I Ain’t Afraid of No Ghosts by Jhey
Here’s another shooter game – but with a twist. This time around, we’re hunting down ghosts in a whack-a-mole type of setup. The difference here is that you only have 15 seconds to work with. It’s a good demonstration of timing animations with CSS. How many can you blast?
See the Pen Pure CSS ghost bustin’ game w/ CSS variables 👻🕹#CodePenChallenge by Jhey
Stack ‘em High by Jerry Low
Reminiscent of Tetris, this game challenges you to stack groups of moving blocks on top of each other. It may sound easy enough but requires precise timing to get right. Now, if I could just find my old Game Boy!
See the Pen Pure CSS Game:Stacker by Jerry Low
You Sunk My Battleship by Daniel Schulz
Grab a friend (or your alter ego) and play a spirited game of Battleship – powered only by CSS.
While it’s not quite as secretive as the physical version, it does provide an excellent foray into conditional logic. Take a look through the code to see how it works.
See the Pen CSS Game:Battleships by Daniel Schulz
Playing Around With CSS
CSS provides us with more than just a way to make our websites look attractive. It can bring movement and interactivity as well.
And, though the games in this collection may not be practical for everyday use, they demonstrate just how powerful the language has become. Studying these examples can provide you with an idea of how to leverage CSS to build more interactive experiences.
- Set Your Text in Motion with These Dazzling Effects
- 7 Fantastic Examples of Variable Fonts in Action
- 8 CSS Snippets for Creating Unique Horizontal Rules & Dividers