Use th for headers, whether they run horizontally or vertically. You can have both a row heading and a column heading in one table. You can also add an optional scope attribute that will improve accessibility, give you a hook so that you can style them differently with CSS, and makes sense clear for ease of maintenance.
The scope attribute indicates the set of data cells for which the current header cell provides header information. The row value provides header information for the rest of the line that contains it. And the col value provides header information for the rest of the column containing it.
Learn more about the area attribute.
<table> <tr> <th scope="row">id</th> <th scope="col">1</th> <th scope="col">2</th> <th scope="col">3</th> </tr> <tr> <th scope="row">name</th> <td>John</td> <td>Smith</td> <td>Khan</td> </tr> <tr> <th scope="row">country</th> <td>America</td> <td>Mexico</td> <td>India</td> </tr> </table>
EDIT : CSS Example
th[scope=row] { color: green } th[scope=col] { color: blue }
source share