A table-like layout using buttons as cards
The question arose; Should I use clickable table rows or individual cards? The conclusion I came to was to use cards.
Example
Click a card button to see what would actually be read aloud by a screen-reader.
The code
HTML
CSS
Features
- The header section is a visual only, hidden by aria-hidden, and not read aloud by a screen-reader. Don't do this if the headers are clickable for sorting (beyond scope).
- Cards are presented as a list of buttons.
- The card container is a button element for the best semantics, built in accessibility, and the least JavaScript.
- Button content is vocalised primarily by
aria-labelledby
indexed non-visual content, which allows the audio order to slightly differ from the visual order. - Button secondary content vocalisation is supplied by
aria-describedby
indexed non-visual content, which allows the audio order to slightly differ from the visual order. - Visual and audio order are completely separated. For example: Name and Amount may be most important fields but they're the furthest apart visually.
Caveat: Reflow at mobile viewports, 200% font-size, and dark mode, are beyond the scope of this demo.