Question

I'm working on a browser based game, and want to keep the HTML as semantically correct as possible.

The base of the game is a "board" made up of a grid of tiles. The coordinates of each tile are used as a way to refer to each tile - much like in Battleships.

Would it be correct semantic markup to use a table to represent this kind of "map" grid, or as it's not a table of figures, would it be more correct to use block level elements such as divs to build up the grid? Example coordinate grid

[edit] In response to some comments, if I should/shouldn't use <table> - why not?

Was it helpful?

Solution

Screen reader or text browser users would have a hard time to play this game if you’d not use a table.

If you use div elements to build that grid, you would have to be very verbose about which cell has which coordinates (each cell would need to be labeled explicitly), and the players would need to concentrate to "rebuild" this grid in their mind. Like playing chess via phone. Possible, yes, but harder than having the board in front of you.

So yes, I think you should use a table. The order of grid cells is important and meaningful, and each cell is labeled by two headings (x/y axis).

Using a table, your grid would be perfectly usable by screen reader users (most screen readers can announce the headings/coordinates of the cells) and in a text browser, too (w3m in this case):

enter image description here

Try that without a table. div elements have no concept of top/right/bottom/left neighbours.

OTHER TIPS

It has the hallmarks of a table. 2D, header cells for both axes, and the meaning of the content would change if the tiles were laid out differently.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top