Search code examples
htmlhtml-tablecolumn-width

HTML5 Tabular data align td content


I'm attempting to create tabular data in HTML5: I'm well versed in tables in (X)HTML and quite fan of the way to specify columns widths with <colgroup> <col width=?> but I've understood that using colgroups in html5 is obsolete. The way to go is using CSS. For small tables this is not a problem. My problem is that my tables are quite large and have over hundreds to rows. Specify a class or style for each <td> most will cause the size of the html code to explode and also could cause performance problems.

What is a proper way of efficiently specify column widths and textalignments on larger a tables in html5?


Solution

  • Use styled <col> in a <colgroup> to specify widths. Style <td> and <th> for text alignment