Menu

Spec tables on product pages: keep them as real tables, and make them work on a phone
πŸ“°

Spec tables on product pages: keep them as real tables, and make them work on a phone

DEV Community: cssΒ·RAMOΒ·about 2 hours ago
#mBeO1LlV
#devtocss#devto#dev#table#specs
Reading 0:00
15s threshold

Every hardware or electronics product page ends up with a spec table. Thread size, length, material, voltage range, what's in the box. It's the part of the page people scroll straight to when they already know what they want.

It's also the part that gets built as a pile of <div> s, or a two-column grid that falls apart below 400px. A few notes on doing it in a way that holds up.

Use a table. It is tabular data.

Key/value specs are exactly what <table> is for. You get row and header relationships for free, and screen readers can announce "Material, stainless steel" instead of two unrelated words.

<table class = "specs" > <caption> Specifications </caption> <tbody> <tr> <th scope = "row" > Material </th> <td> Stainless steel A2 </td> </tr> <tr> <th scope = "row" > Thread </th> <td> M8 </td> </tr> <tr> <th scope = "row" > Length </th> <td> 60 mm </td> </tr> </tbody> </table>

Enter fullscreen mode

Exit fullscreen mode

The two details people skip: scope="row" on the label cell, and a <caption> .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.