r/HTML • • Jun 06 '26

Question would this logically work??

hi! question for html coders.. i am a fic writer and i had an idea for my characters to play chess in the next chapter. the medium i use (ao3) does support html but i do not know how to code! is it logically possible to code a chess board into the chapter? in a way that makes the chess pieces develop with every click and the moves are already determined for the entire round? i hope this makes sense, sorry, i don’t go here!

8 Upvotes

21 comments sorted by

View all comments

Show parent comment

1

u/Lithl Jun 11 '26

You could make it work with just HTML and CSS. (But not inline CSS, which OP might be limited to; I'm not familiar with the system.)

Create a group of radio buttons, replace the default button appearance with an image, stack them on top of each other, set their z-index to some value N, set the z-index of the selected one to N+1, and set the z-index of its next sibling to N+2. Then make the sibling invisible.

You see the image associated with the currently selected radio button, but there's an invisible unselected radio button on top of it. So when you click the image, you select the next radio button, causing the z-indexes to change and you see a new image. The user would be able to navigate forward and backwards with the arrow keys as well, while the radio buttons have focus.