Search code examples
htmlcsshtml-tablecss-grid

CSS Grid or HTML Table


I have something that could definitely be an HTML Table, however, I wonder if creating it as a CSS Grid would be better.

Section as an HTML Table or CSS Grid

The 1, 2, 3, 4 row may or may not be there depending on the data that is pulled in. However, those headers (1,2,3,4) will be replaced with different names, again depending on the data. And I want the data below them in each row to be in alignment and the same width as those columns.

I know how to fairly easily make this work with HTML Tables, with the main nuance being the Col-2 header would need to colspan potentially.

I'd assume this is a fairly straightforward task with CSS grid, however, I figured to ask here.


Solution

  • I would rather use HTML table. Because it makes your code look easier to understand with <th> for headers and <td> for cells data. On the other hand, CSS grid requires you to declare more classes and style it just to make it work like the HTML table, which takes more time, effort.