DEV Community

Discussion on: Why we need CSS subgrid

 
tigt profile image
Taylor Hunt

Wow, super in-depth follow-up. Thanks for your time!

  • The lack of borders and padding might/could be fixed with display:table-row-group and border-spacing.

  • Making the headers full-width might work by leaving them out of the table layout algorithm — leave ’em as block, and reorient where the cells start by abusing writing-mode. (I’ve done things I’m not proud of.)

…but all that’s definitely deep in the weeds of hackiness. (And let’s not talk about display:table-caption, which hoists the child box out of the border-box of its parent.)

If the CSS Table Layout specification had equivalents to colspan and rowspan, we would have been halfway to Grid in 2009. But I can’t blame them for underspecifying the weirdest, most browser-specific layout system ever accidented.

Thread Thread
 
kenbellows profile image
Ken Bellows

Good idea, forgot about display: table-row-group, that does make the borders somewhat work again.

But leaving the header and .top wrapper as a block doesn't fix the colspan problem, which is now manifesting in a really weird way... Without checking the spec, it feels like the children of a table-row-group are in some sort of all-or-nothing pact, where if any one of them is given display: table-row (and has at least one table-cell child?), they all act like table-rows with table-cell children. But if none of them have a table display type, they act like blocks, even if one has table-cell children...

  • nothing has table-row: pen
  • only .counts has table-row: pen

Yeah, I have mixed feelings about CSS Tables. I almost think it's better that it was kept small and arguably incomplete; maybe its holes helped motivate CSS Grid? Maybe if it had been more complete, people would have continually pointed to tables whenever someone brought up Grid, the same way some currently point to display: contents when someone mentions subgrids. But on the other hand, if we're going to have a table layout system anyway, might as well make it fully functional. Maybe they could augment it now to complete the picture.

Thread Thread
 
kenbellows profile image
Ken Bellows

By the way, thanks for the replies, it's been very interesting! I forget that CSS Tables are a thing, and they're worth remembering for those odd corner cases

Thread Thread
 
sethveale profile image
Seth Veale

Thanks for the write-up and for not flaming someone for mentioning CSS tables. Open inquiry has not been the norm and you're doing good work here.

Thread Thread
 
hebbybomm profile image
hebbybomm

Ken, thanks for giving a great and detailedwrite-up on the need for subgrid.
I've been frustrated by the lack of subgrid on grid frameworks for a while now.