Skip to content
Related Articles

Related Articles

Improve Article
How to create a header cell in a table using HTML5 ?
  • Last Updated : 15 Oct, 2020

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



My Personal Notes arrow_drop_up
Recommended Articles
Page :