This fiddle says it all, but let's go briefly over it.
Whenever you are building a table out of a tree, use <table>
, <tr>
, <td>
tags or their CSS equivalents table
, table-row
and table-cell
and apply display:contents
to the elements that you intreleave with the table to preserve your tree without destroying the table layout.
Easy-peasy, but it took me a while to figure it out.