Horje
How to create HTML Table Headers

Sometimes you want your cells to be table header cells. In those cases use the <th> tag instead of the <td> tag:


Example of Table Headers

th stands for table header.
 <table>
  <tr>
    <th>Person 1</th>
    <th>Person 2</th>
    <th>Person 3</th>
  </tr>
  <tr>
    <td>Emil</td>
    <td>Tobias</td>
    <td>Linus</td>
  </tr>
  <tr>
    <td>16</td>
    <td>14</td>
    <td>10</td>
  </tr>
</table> 

Full Example of Table Headers

Let the first row be table header cells: By default, the text in <th> elements are bold and centered, but you can change that with CSS.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<style>
table, th, td {
  border:1px solid black;
}
</style>
<body>

<h2>TH elements define table headers</h2>

<table style="width:100%">
  <tr>
    <th>Person 1</th>
    <th>Person 2</th>
    <th>Person 3</th>
  </tr>
  <tr>
    <td>Emil</td>
    <td>Tobias</td>
    <td>Linus</td>
  </tr>
  <tr>
    <td>16</td>
    <td>14</td>
    <td>10</td>
  </tr>
</table>

<p>To understand the example better, we have added borders to the table.</p>

</body>
</html>

Output should be:

Full Example of Table Headers
Reffered: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table6





Related Articles
What is HTML Tables HTML Tables
How to create an HTML Table HTML Tables
How to create HTML Table Cells HTML Tables
How to create HTML Table Rows HTML Tables
How to create HTML Table Headers HTML Tables

Single Articles
Example of Table HeadersHTML Tables
Full Example of Table HeadersHTML Tables

Read Full:
HTML Tables
Category:
Web Tutorial
Sub Category:
HTML Tables
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
35



Share on: