Menu

Table Headers and Captions

Table Headers and Captions

Instead of using td for header cells, HTML has a dedicated tag called th, short for table header. Browsers automatically bold and center this text to make it stand out.

You can also add a caption to describe the table using the caption tag right after the opening table tag.

<table>

  <caption>Employee Details</caption>

  <tr>

    <th>Name</th>

    <th>Department</th>

  </tr>

  <tr>

    <td>Priya</td>

    <td>Design</td>

  </tr>

</table>

Explanation: Using th instead of td for the top row is not just about looks. It tells screen readers and search engines that this row labels the columns below it, which matters for accessibility.


HTML Tutorial (From Basics to Implementation)

AP

Abhishek Pati





Get in Touch For Details