Open In App

How to create a header cell in a table using HTML5 ?

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will create a header cell in a table. The approach of this article is to create a Header cell in an HTML table. It is used to set the header cell of a table. The Header cell is used to hold the header information.

Syntax:

<th> Contents... </th>

Example:




<!DOCTYPE html>
<html>
  
<head>
   <style>
      body {
         text-align: center;
      }
  
      h1 {
         color: green;
      }
  
      th {
         color: blue;
      }
  
      table,
      tbody,
      td {
         border: 1px solid black;
         border-collapse: collapse;
         margin: 0 auto;
      }
   </style>
</head>
  
<body>
   <h1>GeeksforGeeks</h1>
   <h2>How to create a header cell
      in a table using HTML5 ?</h2>
   <table>
      <thead>
         <tr>
            <!-- th M starts here -->
            <th> MEDICINES</th>
            <th>Batch No.</th>
            <!-- th tag end here -->
         </tr>
      </thead>
      <tbody>
         <tr>
            <td>Paracetamol</td>
            <td>123</td>
         </tr>
         <tr>
            <td>Aplazar</td>
            <td>12345</td>
         </tr>
      </tbody>
   </table>
</body>
  
</html>                    


Output:

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Last Updated : 15 Oct, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads