Most common way of writing a HTML table with vertical headers?

First, your second option isn’t quite valid HTML in the sense that all of the rows (TR) in a table should contain an equal number of columns (TD). Your header has 1 while the body has 3. You should use the colspan attribute to fix that.

Reference: “The THEAD, TFOOT, and TBODY sections must contain the same number of columns.” – Last paragraph of section 11.2.3.

With that being said, the first option is the better approach in my opinion because it’s readable regardless of whether or not I have CSS enabled. Some browsers (or search engine crawlers) don’t do CSS and as such, it’ll make your data make no sense as the header will then represent columns instead of rows.

Leave a Comment