Computer >> Computer tutorials >  >> Programming >> HTML

How to add one or more header cells a cell is related to in HTML?


Use the headers attribute in HTML to add one or more header cells a cell is related to in HTML.

Example

You can try to run the following code to implement the headers attribute −

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 2px solid blue;
         }
      </style>
   </head>
   <body>
      <table style = "width:100%">
         <tr>
            <th id = "name">Subject ID</th>
            <th id = "email">Subject Name</th>
         </tr>
         <tr>
            <td headers = "name">001</td>
            <td headers = "email">Mathematics</td>
         </tr>
      </table>
   </body>
</html>