Is is wrong or bad to add padding to represent hierarchy in tables?

I got data that is a list of items, got a name and category. Each item could have children, with name and categories there too. And I would like to show all of them. I was thinking of adding a left-padding on the children, making them indented. Am I thinking about this wrong? Is there a better way?
7 Replies
majkl
majkl10mo ago
Isn`t <thead> background and zebra more convenient?
Jochem
Jochem10mo ago
if there's a hierarchy in the data, you should try to represent that in your markup as well. Hierarchical data doesn't fit well in the classic tabular data structure of a table though, so it's hard to say what would be best without a concrete example
Zerthz
ZerthzOP10mo ago
What i'm recreating is basically looking like this. and i was thinking of adding padding, but yes that is not going to be obvious from the markup
No description
Zerthz
ZerthzOP10mo ago
and there could ofc be more of the areas underneath it would be nice to keep to some kind of semantc html, but might have to roll some list solution?
Jochem
Jochem10mo ago
I'm honestly not sure there is a good solution for this, from a semantic and accessibility point of view. Technically, semantically the sublocations should probably be in a nested table, but screen readers apparently handle those badly, so you shouldn't do that for accessibility reasons. I tried looking into some aria-* roles, but I'm no expert there unfortunately. I don't think there's a way to use them properly in this case
Zerthz
ZerthzOP10mo ago
if we ignore the accessibility just for sake of argument. what do you think would suck the least to build? tables with padding-indent or using Unordered Lists with nesting and make it look like a table?
Jochem
Jochem10mo ago
table, definitely you just add a sublocation class on the tr it's still mostly tabular data
Want results from more Discord servers?
Add your server