Hope you enjoyed! If you're curious how this works: HTML has a native element called details, which toggles open and closed when you click it. That's the only "interactivity" in this entire game. The trick is CSS :has(), a selector that lets a parent element react to the state of its children. So when you click a cell, its details opens, and CSS detects whether that cell has the ship class — if it does, it shows a ✕ and a red background; if not, it shows a • and a dark background. The fleet status panel watches for all cells belonging to a given ship being open simultaneously, and flips that ship's status from AFLOAT to SUNK. The win condition works the same way: once all fifteen ship cells are open, the victory banner appears and a transparent overlay locks the board.
---
If this moved you, even a little, please consider leaving a kudos or some feedback. I’ve poured a lot of time, love, and late-night tinkering into this. It's part of a new fixation, and I would love to hear everyone's thoughts.
Lately, I’ve realized: I have free will. Which means I’ve been joyfully and chaotically experimenting with HTML formatting and custom workskins.
Please stay tuned for the next HTML piece! I will post/update something in this series weekly OR biweekly; if you want to stay updated on this HTML series, please consider subscribing or bookmarking.
You can find me on Bluesky ( @the_wild_poet25 ) and on Twitter (the_tamed_poet) if you want to connect. I'm also on Discord too!
The comment section also works—feel free to leave a comment! :)